From 18cd2f8066db91f5172e5638f3e694e0e74aac36 Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Sun, 9 Sep 2012 14:23:56 +0200 Subject: [PATCH] Fix some PDO implementation stuff --- class.databaserecord.php | 13 ++++++++++++- include.memcache.php | 9 +++++---- include.mysql.php | 1 + 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/class.databaserecord.php b/class.databaserecord.php index 9511e73..b28a1b1 100644 --- a/class.databaserecord.php +++ b/class.databaserecord.php @@ -360,6 +360,8 @@ abstract class CPHPDatabaseRecordClass extends CPHPBaseClass public function InsertIntoDatabase() { + global $cphp_config, $database; + if(!empty($this->verify_query)) { if($this->sId == 0) @@ -499,7 +501,15 @@ abstract class CPHPDatabaseRecordClass extends CPHPBaseClass { if($insert_mode == CPHP_INSERTMODE_INSERT) { - $this->sId = mysql_insert_id(); + /* Temporary PDO implementation. */ + if(!empty($cphp_config->database->pdo)) + { + $this->sId = $database->lastInsertId(); + } + else + { + $this->sId = mysql_insert_id(); + } } $this->RefreshData(); @@ -509,6 +519,7 @@ abstract class CPHPDatabaseRecordClass extends CPHPBaseClass else { $classname = get_class($this); + var_dump($database->errorInfo()); throw new DatabaseException("Database insertion query failed in object of type {$classname}. Error message: " . mysql_error()); } } diff --git a/include.memcache.php b/include.memcache.php index f88057c..7d78b60 100644 --- a/include.memcache.php +++ b/include.memcache.php @@ -148,9 +148,10 @@ function mysql_query_cached($query, $expiry = 60, $key = "", $exec = false) { mc_set($key, $result, $expiry); } - + + $return_object = new stdClass; $return_object->source = "database"; - $return_object->data = $result; + $return_object->data = $data; return $return_object; } @@ -172,10 +173,10 @@ function mysql_query_cached($query, $expiry = 60, $key = "", $exec = false) { return null; } - elseif($statement == 0) + /*elseif($statement == 0) { return false; - } + }*/ else { $return_object = new stdClass(); diff --git a/include.mysql.php b/include.mysql.php index d014e32..fab0c4e 100644 --- a/include.mysql.php +++ b/include.mysql.php @@ -112,6 +112,7 @@ class CachedPDO extends PDO } else { + /* This will fire when there are zero results AND on syntax errors. */ return null; } }