"Fix'd" the execute query to pass args array without binding, assuming the first value is at index 0 and the query uses questionmarks.

This commit is contained in:
Diftraku 2011-03-05 03:11:29 +02:00
parent 065102016a
commit 3d66c7ce41

View File

@ -325,6 +325,7 @@ class Database {
public function execute($query, $args=array()) { public function execute($query, $args=array()) {
try { try {
$stmt = $this->db->prepare($query); $stmt = $this->db->prepare($query);
if (!array_key_exists(0, $args)) {
foreach($args as $name=>$value) { foreach($args as $name=>$value) {
if(is_numeric($value)) { if(is_numeric($value)) {
$stmt->bindValue(":$name", $value, PDO::PARAM_INT); $stmt->bindValue(":$name", $value, PDO::PARAM_INT);
@ -334,6 +335,10 @@ class Database {
} }
} }
$stmt->execute(); $stmt->execute();
}
else {
$stmt->execute($args);
}
return $stmt; return $stmt;
} }
catch(PDOException $pdoe) { catch(PDOException $pdoe) {