diff --git a/class.databaserecord.php b/class.databaserecord.php index 1943068..9511e73 100644 --- a/class.databaserecord.php +++ b/class.databaserecord.php @@ -495,7 +495,7 @@ abstract class CPHPDatabaseRecordClass extends CPHPBaseClass $query = "UPDATE {$this->table_name} SET {$sQueryKeysValues} WHERE `{$this->id_field}` = '{$this->sId}'"; } - if($result = mysql_query_cached($query, 0)) + if($result = mysql_query_cached($query, 0, "", true)) { if($insert_mode == CPHP_INSERTMODE_INSERT) { diff --git a/include.memcache.php b/include.memcache.php index cddae1b..a14ac4e 100644 --- a/include.memcache.php +++ b/include.memcache.php @@ -90,7 +90,7 @@ function mc_delete($key) } } -function mysql_query_cached($query, $expiry = 60, $key = "") +function mysql_query_cached($query, $expiry = 60, $key = "", $exec = false) { global $cphp_config, $database; @@ -138,7 +138,7 @@ function mysql_query_cached($query, $expiry = 60, $key = "") else { /* Transparently use PDO to run the query. */ - if($statement = $database->Query($query)) + if($exec === false && $statement = $database->query($query)) { if($data = $statement->fetchAll(PDO::FETCH_ASSOC)) { @@ -151,6 +151,8 @@ function mysql_query_cached($query, $expiry = 60, $key = "") $return_object->source = "database"; $return_object->data = $result; + + return $return_object; } else { @@ -162,6 +164,25 @@ function mysql_query_cached($query, $expiry = 60, $key = "") return null; } } + elseif($exec === true) + { + $statement = $database->exec($query); + + if(is_null($statement)) + { + return null; + } + elseif($statement == 0) + { + return false; + } + else + { + $return_object->source = "database"; + $return_object->data = $result; + return $return_object; + } + } else { return null;