lithium\data\source\Database::update()
Implements
lithium\data\Source::update()
Updates a record in the database based on the given Query
.
Parameters
-
object
$query
A
lithium\data\model\Query
object -
array
$options
none
Returns
booleanFilter
This method can be filtered.
Source
public function update($query, array $options = []) {
$params = compact('query', 'options');
return Filters::run($this, __FUNCTION__, $params, function($params) {
$query = $params['query'];
$exportedQuery = $query->export($this);
if ($exportedQuery['fields'] === null) {
return true;
}
$sql = $this->renderCommand('update', $exportedQuery, $query);
$result = (boolean) $this->_execute($sql);
if ($result && is_object($query) && $query->entity()) {
$query->entity()->sync();
}
return $result;
});
}