lithium\data\Model::query()

public static method

Gets or sets the default query for the model.

Parameters

  • array $query

    Possible options are:

    • 'conditions': The conditional query elements, e.g. 'conditions' => ['published' => true]
    • 'fields': The fields that should be retrieved. When set to null, defaults to all fields.
    • 'order': The order in which the data will be returned, e.g. 'order' => 'ASC'.
    • 'limit': The maximum number of records to return.
    • 'page': For pagination of data.
    • 'with': An array of relationship names to be included in the query.

Returns

mixed

Returns the query definition if querying, or null if setting.

Source

	public static function query($query = null) {
		$self = static::object();

		if (!$query) {
			return $self->_query;
		}
		$self->_query = $query + $self->_query;
	}