lithium\data\source\Database::delete PHP Method

delete() public method

Deletes a record in the database based on the given Query.
public delete ( object $query, array $options = [] ) : boolean
$query object An SQL string, or `lithium\data\model\Query` object instance.
$options array If `$query` is a string, `$options` is the array of quoted/escaped parameter values to be inserted into the query.
return boolean Returns `true` on successful query execution (not necessarily if records are deleted), otherwise `false`.
    public function delete($query, array $options = array())
    {
        return $this->_filter(__METHOD__, compact('query', 'options'), function ($self, $params) {
            $query = $params['query'];
            $isObject = is_object($query);
            if ($isObject) {
                $sql = $self->renderCommand('delete', $query->export($self), $query);
            } else {
                $sql = String::insert($query, $self->value($params['options']));
            }
            $result = (bool) $self->invokeMethod('_execute', array($sql));
            if ($result && $isObject && $query->entity()) {
                $query->entity()->sync(null, array(), array('dematerialize' => true));
            }
            return $result;
        });
    }