summaryrefslogtreecommitdiffstats
path: root/phpfspot_db.php
diff options
context:
space:
mode:
authorAndreas Unterkircher <unki@netshadow.at>2007-06-09 06:37:44 +0000
committerAndreas Unterkircher <unki@netshadow.at>2007-06-09 06:37:44 +0000
commitdac334b46e3f2d939f8d106b98dc82a102e72423 (patch)
treed4b4cb0a6f1c361615967c1d613c19b2bf0f1afd /phpfspot_db.php
parentfd6a1fceaa36f71f8c7bd88be0c44b1a26907517 (diff)
general function to check if a table exists
general function to execute a query without handling results git-svn-id: file:///var/lib/svn/phpfspot/trunk@64 fa6a889d-dae6-447d-9e79-4ba9a3039384
Diffstat (limited to 'phpfspot_db.php')
-rw-r--r--phpfspot_db.php27
1 files changed, 22 insertions, 5 deletions
diff --git a/phpfspot_db.php b/phpfspot_db.php
index 6c86563..585e559 100644
--- a/phpfspot_db.php
+++ b/phpfspot_db.php
@@ -110,6 +110,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 +196,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;