* 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
*
***************************************************************************/
-/* from pear "MDB2" package. use "pear install MDB2" if you don't have this! */
-require_once('MDB2.php');
-
class PHPFSPOT_DB {
private $db;
if($this->getConnStatus()) {
if(($result = sqlite3_query($this->db, $query)) === false)
- $this->trowError($this->getLastError());
+ $this->ThrowError($this->getLastError());
return $result;
}
} // 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);
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;
private function getLastError()
{
-
- return sqlite3_error_string(sqlite3_last_error($this->db));
+ return sqlite3_error($this->db);
} // getLastError()