lithium\data\source\Database::delete()
Implements
lithium\data\Source::delete()
Deletes a record in the database based on the given Query.
Parameters
-
object
$queryAn SQL string, or
lithium\data\model\Queryobject instance. -
array
$optionsIf
$queryis a string,$optionsis the array of quoted/escaped parameter values to be inserted into the query.
Returns
booleanReturns true on successful query execution (not necessarily if records are
deleted), otherwise false.
Filter
This method can be filtered.
Source
public function delete($query, array $options = []) {
$params = compact('query', 'options');
return Filters::run($this, __FUNCTION__, $params, function($params) {
$query = $params['query'];
$isObject = is_object($query);
if ($isObject) {
$sql = $this->renderCommand('delete', $query->export($this), $query);
} else {
$sql = Text::insert($query, $this->value($params['options']));
}
$result = (boolean) $this->_execute($sql);
if ($result && $isObject && $query->entity()) {
$query->entity()->sync(null, [], ['dematerialize' => true]);
}
return $result;
});
}