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

create() public method

Inserts a new record into the database based on a the Query. The record is updated with the id of the insert.
See also: lithium\util\String::insert()
public create ( object $query, array $options = [] ) : boolean
$query object An SQL query string, or `lithium\data\model\Query` object instance.
$options array If $query is a string, $options contains an array of bind values to be escaped, quoted, and inserted into `$query` using `String::insert()`.
return boolean Returns `true` if the query succeeded, otherwise `false`.
    public function create($query, array $options = array())
    {
        return $this->_filter(__METHOD__, compact('query', 'options'), function ($self, $params) {
            $query = $params['query'];
            $model = $entity = $object = $id = null;
            if (is_object($query)) {
                $object = $query;
                $model = $query->model();
                $params = $query->export($self);
                $entity =& $query->entity();
                $query = $self->renderCommand('create', $params, $query);
            } else {
                $query = String::insert($query, $self->value($params['options']));
            }
            if (!$self->invokeMethod('_execute', array($query))) {
                return false;
            }
            if ($entity) {
                if ($model && !$model::key($entity)) {
                    $id = $self->invokeMethod('_insertId', array($object));
                }
                $entity->sync($id);
            }
            return true;
        });
    }