general function to check if a table exists
[phpfspot.git] / phpfspot.class.php
index de2adc086f001265f2d53123c7048493f10f187d..d62be697f2c0677878dff847f7e72edb255d846c 100644 (file)
@@ -19,7 +19,10 @@ class PHPFSPOT {
       $this->cfg = new PHPFSPOT_CFG;
 
       $this->db = new PHPFSPOT_DB(&$this, $this->cfg->fspot_db);
+
       $this->cfg_db = new PHPFSPOT_DB(&$this, $this->cfg->phpfspot_db);
+      $this->check_config_table();
+
       $this->tmpl = new PHPFSPOT_TMPL($this);
 
       $this->get_tags();
@@ -343,6 +346,20 @@ class PHPFSPOT {
 
    } // get_meta_informations()
 
+   public function check_config_table()
+   {
+      // if the config table doesn't exist yet, create it
+      if(!$this->cfg_db->db_check_table_exists("images")) {
+         $this->cfg_db->db_exec("
+            CREATE TABLE images (
+               img_idx int primary key,
+               img_md5 varchar(32)
+            )
+            ");
+      }
+
+   } // check_config_table
+
 }
 
 ?>