X-Git-Url: https://git.nubati.net/cgi-bin/gitweb.cgi?p=phpfspot.git;a=blobdiff_plain;f=phpfspot_db.php;h=fba87b3dc818b4eb172067fb9a0f610709c274a2;hp=6c86563ed962ca8b813aae3ff3b1bdb4a42048a4;hb=b8a78ac21a0c1d90f773612b69e126c79b00c768;hpb=89f91f657ec8ee7f53c974292c0f3dd91e9e785e diff --git a/phpfspot_db.php b/phpfspot_db.php index 6c86563..fba87b3 100644 --- a/phpfspot_db.php +++ b/phpfspot_db.php @@ -8,7 +8,7 @@ * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -21,9 +21,6 @@ * ***************************************************************************/ -/* from pear "MDB2" package. use "pear install MDB2" if you don't have this! */ -require_once('MDB2.php'); - class PHPFSPOT_DB { private $db; @@ -110,6 +107,24 @@ class PHPFSPOT_DB { } // db_query() + /** + * PHPFSPOT_DB database query & execute + * + * This function will execute a SQL query and return nothing. + */ + public function db_exec($query = "") + { + if($this->getConnStatus()) { + + if(($result = sqlite3_exec($this->db, $query)) === false) + $this->ThrowError($this->getLastError()); + + } + else + $this->ThrowError("Can't execute query - we are not connected!"); + + } // db_exec() + public function db_fetch_object(&$resource) { return sqlite3_fetch_array($resource); @@ -178,11 +193,10 @@ class PHPFSPOT_DB { public function db_check_table_exists($table_name = "") { if($this->getConnStatus()) { - $result = $this->db_query("SHOW TABLES"); - $tables_in = "Tables_in_". MYSQL_DB; - - while($row = $result->fetchRow()) { - if($row->$tables_in == $table_name) + + $result = $this->db_query("SELECT name FROM sqlite_master WHERE type='table'"); + while($table = $this->db_fetch_object($result)) { + if($table['name'] == $table_name) return true; } return false;