X-Git-Url: https://git.nubati.net/cgi-bin/gitweb.cgi?p=phpfspot.git;a=blobdiff_plain;f=phpfspot_db.php;h=e0cf39f31a89df601b5352608849228cfdd7ad90;hp=1f7d59716a8a65d7df62e8dd92ccae260ad92609;hb=dcc26041d1dd86d47516e143fd5e475e588180cf;hpb=dc12bd176c6c6e9f7164cc9a97a2f1d902a7404e
diff --git a/phpfspot_db.php b/phpfspot_db.php
index 1f7d597..e0cf39f 100644
--- a/phpfspot_db.php
+++ b/phpfspot_db.php
@@ -2,8 +2,9 @@
/***************************************************************************
*
- * Copyright (c) by Andreas Unterkircher, unki@netshadow.at
- * All rights reserved
+ * phpfspot, presents your F-Spot photo collection in Web browsers.
+ *
+ * Copyright (c) by Andreas Unterkircher
*
* 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
@@ -21,6 +22,11 @@
*
***************************************************************************/
+/**
+ * PHPFSPOT_DB class
+ *
+ * @package phpfspot
+ */
class PHPFSPOT_DB {
private $db;
@@ -28,6 +34,7 @@ class PHPFSPOT_DB {
private $parent;
private $is_connected;
private $last_error;
+ private $last_query;
/**
* PHPFSPOT_DB class constructor
@@ -36,13 +43,15 @@ class PHPFSPOT_DB {
*/
public function __construct($parent, $db_path)
{
- $this->parent = $parent;
+ global $phpfspot;
+
+ $this->parent = $phpfspot;
$this->db_path = $db_path;
/* We are starting disconnected */
$this->setConnStatus(false);
- /* Connect to MySQL Database */
+ /* Connect to database */
$this->db_connect();
} // __construct()
@@ -72,6 +81,7 @@ class PHPFSPOT_DB {
$this->setConnStatus(false);
}
else {
+ sqlite3_create_function($this->db, 'basename', 1, 'basename');
$this->setConnStatus(true);
}
break;
@@ -118,6 +128,8 @@ class PHPFSPOT_DB {
public function db_query($query = "")
{
if($this->getConnStatus()) {
+
+ $this->last_query = $query;
switch($this->parent->cfg->db_access) {
case 'native':
@@ -153,6 +165,8 @@ class PHPFSPOT_DB {
{
if($this->getConnStatus()) {
+ $this->last_query = $query;
+
switch($this->parent->cfg->db_access) {
case 'native':
if(($result = sqlite3_exec($this->db, $query)) === false)
@@ -197,10 +211,10 @@ 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];
+ $row = $result->fetch();
break;
}
return $row;
@@ -229,19 +243,6 @@ class PHPFSPOT_DB {
} // db_getNumRows()
- /**
- * PHPFSPOT_DB get primary key
- *
- * This function returns the primary key of the last
- * operated insert SQL query.
- */
- public function db_getid()
- {
- /* Get the last primary key ID from execute query */
- return mysql_insert_id($this->db->connection);
-
- } // db_getid()
-
/**
* PHPFSPOT_DB check table exists
*
@@ -308,6 +309,7 @@ class PHPFSPOT_DB {
private function ThrowError($string)
{
if(!defined('DB_NOERROR')) {
+ print "Error during query: ". $this->last_query ."
\n";
print "
". $string ."
\n";
try {
throw new Exception;