add new update function

This commit is contained in:
Jianxuan Li 2015-05-02 18:06:35 +08:00
parent 4905190441
commit 769f2dbb14
1 changed files with 14 additions and 1 deletions

View File

@ -83,9 +83,22 @@ class Record extends AbstractEventManager {
$id = $dbh->update($table,$data,$where,true);
}
elseif($where instanceof Sql\Where)
elseif($where instanceof Sql\Where || is_callable($where))
{
try{
$adapter = Db::getInstance();
$sql = new Sql\Sql($adapter);
$update = $sql->update($table);
$update->where($where);
$update->set($data);
$statement = $sql->prepareStatementForSqlObject($update);
return $statement->execute();
}catch (\Exception $e){
throw new RecordException($e->getMessage(),$e->getCode());
}
}
elseif(is_array($where))