From e8bc8f7d5f8dea6906f6e61ba464353c92e87ccf Mon Sep 17 00:00:00 2001 From: Andreas Unterkircher Date: Sun, 30 Dec 2007 11:17:16 +0100 Subject: [PATCH] issue82, read out F-Spot DB version to differ between different databases schemas --- phpfspot.class.php | 28 ++++++++++++++++++++++++++-- phpfspot_db.php | 2 +- themes/default/templates/credits.tpl | 2 ++ 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/phpfspot.class.php b/phpfspot.class.php index e2b24a8..6d357e5 100644 --- a/phpfspot.class.php +++ b/phpfspot.class.php @@ -32,6 +32,7 @@ class PHPFSPOT { var $tmpl; var $tags; var $avail_tags; + private $dbver; /** * class constructor @@ -58,7 +59,9 @@ class PHPFSPOT { print $this->cfg->fspot_db ." is not writeable for user ". $this->getuid() ."\n"; exit(1); } - + + $this->dbver = $this->getFspotDBVersion(); + if(!is_writeable(dirname($this->cfg->phpfspot_db))) { print dirname($this->cfg->phpfspot_db) .": directory is not writeable!"; exit(1); @@ -1051,6 +1054,7 @@ class PHPFSPOT { { $this->tmpl->assign('version', $this->cfg->version); $this->tmpl->assign('product', $this->cfg->product); + $this->tmpl->assign('db_version', $this->dbver); $this->tmpl->show("credits.tpl"); } // showCredits() @@ -2102,6 +2106,26 @@ class PHPFSPOT { } // checkDbIndices() -} + /** + * retrive F-Spot database version + * + * this function will return the F-Spot database version number + * It is stored within the sqlite3 database in the table meta + */ + public function getFspotDBVersion() + { + if($result = $this->db->db_fetchSingleRow(" + SELECT data as version + FROM meta + WHERE + name LIKE 'F-Spot Database Version' + ")) + return $result['version']; + + return null; + + } // getFspotDBVersion() + +} // class PHPFSPOT ?> diff --git a/phpfspot_db.php b/phpfspot_db.php index 4e87cf9..e9c99ce 100644 --- a/phpfspot_db.php +++ b/phpfspot_db.php @@ -202,7 +202,7 @@ class PHPFSPOT_DB { $result = $this->db_query($query); switch($this->parent->cfg->db_access) { case 'native': - $row = $result->fetchRow(); + $row = $this->db_fetch_object($result); break; case 'pdo': $row = $result[0]; diff --git a/themes/default/templates/credits.tpl b/themes/default/templates/credits.tpl index becdeef..cb01edb 100644 --- a/themes/default/templates/credits.tpl +++ b/themes/default/templates/credits.tpl @@ -17,6 +17,8 @@ HTML_AJAX
PHP tag-cloud code by Jenny Ferenc. +
+ F-Spot database version: {$db_version} -- 2.25.1