|
@ -24,7 +24,7 @@ abstract class Model |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Cache instance |
|
|
* Cache instance |
|
|
* |
|
|
|
|
|
|
|
|
* |
|
|
* @var Cache |
|
|
* @var Cache |
|
|
*/ |
|
|
*/ |
|
|
protected $cache; |
|
|
protected $cache; |
|
@ -32,15 +32,15 @@ abstract class Model |
|
|
protected $table; |
|
|
protected $table; |
|
|
|
|
|
|
|
|
protected $connection = 'default'; |
|
|
protected $connection = 'default'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected $key = 'id'; |
|
|
protected $key = 'id'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function __construct() |
|
|
public function __construct() |
|
|
{ |
|
|
{ |
|
|
$this->db = Db::connect($this->connection); |
|
|
$this->db = Db::connect($this->connection); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* @return int |
|
|
* @return int |
|
|
*/ |
|
|
*/ |
|
@ -113,6 +113,9 @@ abstract class Model |
|
|
*/ |
|
|
*/ |
|
|
public function update($data, $where) |
|
|
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); |
|
|
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 $autoindent ? $this->identify($this->table) : $this->table; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* @return Cache |
|
|
* @return Cache |
|
|
*/ |
|
|
*/ |
|
|