From 9fa1d072fd90f5c5a2132837e62f4a9dab6a06c2 Mon Sep 17 00:00:00 2001 From: Filipp Lepalaan Date: Wed, 18 Nov 2009 13:53:52 +0200 Subject: Controller fixes --- Controller.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'Controller.php') 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); -- cgit v1.2.3