From 4a22759e3dda0594810012a154c7f11a59faa883 Mon Sep 17 00:00:00 2001 From: aterekhov Date: Sat, 13 Mar 2010 17:26:54 +0000 Subject: [PATCH] UPDATE $where similar to INSERT #0 git-svn-id: svn+ssh://code.netmonsters.ru/svn/majestic/branches/evo@123 4cb57b5f-5bbd-dd11-951b-001d605cbbc5 --- model/Model.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/model/Model.php b/model/Model.php index e36c1b8..51fdb18 100644 --- a/model/Model.php +++ b/model/Model.php @@ -24,7 +24,7 @@ abstract class Model /** * Cache instance - * + * * @var Cache */ protected $cache; @@ -32,15 +32,15 @@ abstract class Model protected $table; protected $connection = 'default'; - + protected $key = 'id'; - + public function __construct() { $this->db = Db::connect($this->connection); } - + /** * @return int */ @@ -113,6 +113,9 @@ abstract class Model */ public function update($data, $where) { + if (is_int($where)) { + $where = $this->identify($this->key) . '=' . (int) $where; + } return $this->db->update($this->table(false), $data, $where); } @@ -139,7 +142,7 @@ abstract class Model } return $autoindent ? $this->identify($this->table) : $this->table; } - + /** * @return Cache */