From 3d66c7ce41f1bb7ff056d0f00b21833b0ec29107 Mon Sep 17 00:00:00 2001 From: Diftraku Date: Sat, 5 Mar 2011 03:11:29 +0200 Subject: [PATCH] "Fix'd" the execute query to pass args array without binding, assuming the first value is at index 0 and the query uses questionmarks. --- core/database.class.php | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/core/database.class.php b/core/database.class.php index cfb2abaf..9b2c70c3 100644 --- a/core/database.class.php +++ b/core/database.class.php @@ -325,15 +325,20 @@ class Database { public function execute($query, $args=array()) { try { $stmt = $this->db->prepare($query); - foreach($args as $name=>$value) { - if(is_numeric($value)) { - $stmt->bindValue(":$name", $value, PDO::PARAM_INT); - } - else { - $stmt->bindValue(":$name", $value, PDO::PARAM_STR); + if (!array_key_exists(0, $args)) { + foreach($args as $name=>$value) { + if(is_numeric($value)) { + $stmt->bindValue(":$name", $value, PDO::PARAM_INT); + } + else { + $stmt->bindValue(":$name", $value, PDO::PARAM_STR); + } } + $stmt->execute(); + } + else { + $stmt->execute($args); } - $stmt->execute(); return $stmt; } catch(PDOException $pdoe) {