"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,15 +325,20 @@ 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);
foreach($args as $name=>$value) { if (!array_key_exists(0, $args)) {
if(is_numeric($value)) { foreach($args as $name=>$value) {
$stmt->bindValue(":$name", $value, PDO::PARAM_INT); if(is_numeric($value)) {
} $stmt->bindValue(":$name", $value, PDO::PARAM_INT);
else { }
$stmt->bindValue(":$name", $value, PDO::PARAM_STR); else {
$stmt->bindValue(":$name", $value, PDO::PARAM_STR);
}
} }
$stmt->execute();
}
else {
$stmt->execute($args);
} }
$stmt->execute();
return $stmt; return $stmt;
} }
catch(PDOException $pdoe) { catch(PDOException $pdoe) {