diff options
-rw-r--r-- | Controller.php | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/Controller.php b/Controller.php index 14b7900..34f675b 100644 --- a/Controller.php +++ b/Controller.php @@ -89,7 +89,7 @@ class Controller } $tmp = (empty($q)) ? ' WHERE ' : ' AND '; - $q .= $tmp . $col . ' ' . $op . ' ?'; + $q .= $tmp . "`{$col}`" . ' ' . $op . ' ?'; } } else { @@ -303,7 +303,11 @@ class Controller } $query = ""; $values = array(); - $data = array_merge($data, $where); + list($col, $val) = each($where); + + if (!isset($data[$col])) { + $data = array_merge($data, $where); + } foreach ($data as $k => $v) { $query .= "`$k` = :$k, "; @@ -311,8 +315,6 @@ class Controller } $query = rtrim($query, ", "); - list($col, $val) = each($where); - $sql = "UPDATE `{$this->table}` SET $query WHERE `$col` = :$col"; return Db::query($sql, $values); |