PHP Class JamesMoss\Flywheel\Query

Builds an executes a query whichs searches and sorts documents from a repository.
Mostra file Open project: jamesmoss/flywheel Class Usage Examples

Protected Properties

Property Type Description
$limit
$orderBy
$predicate
$repo

Public Methods

Method Description
__construct ( Repository $repository ) Constructor
andWhere ( string | Closure $field, string $operator = null, string $value = null ) : Query Adds a boolean AND predicate for this query,
execute ( ) : Result Runs the query.
limit ( integer $count, integer $offset ) : Query Set a limit on the number of documents returned. An offset from 0 can also be specified.
orWhere ( string | Closure $field, string $operator = null, string $value = null ) : Query Adds a boolean OR predicate for this query,
orderBy ( mixed $fields ) : Query Sets the fields to order the results by. They should be in the the format 'fieldname ASC|DESC'. e.g 'dateAdded DESC'.
where ( $field, $operator = null, $value = null ) : Query

Method Details

__construct() public method

Constructor
public __construct ( Repository $repository )
$repository Repository The repo this query will run against.

andWhere() public method

Adds a boolean AND predicate for this query,
public andWhere ( string | Closure $field, string $operator = null, string $value = null ) : Query
$field string | Closure The name of the field to match or an anonymous function that will define sub predicates.
$operator string An operator from the allowed list.
$value string The value to compare against.
return Query The same instance of this class.

execute() public method

Runs the query.
public execute ( ) : Result
return Result The documents returned from this query.

limit() public method

Set a limit on the number of documents returned. An offset from 0 can also be specified.
public limit ( integer $count, integer $offset ) : Query
$count integer The number of documents to return.
$offset integer The offset from which to return.
return Query The same instance of this class.

orWhere() public method

Adds a boolean OR predicate for this query,
public orWhere ( string | Closure $field, string $operator = null, string $value = null ) : Query
$field string | Closure The name of the field to match or an anonymous function that will define sub predicates.
$operator string An operator from the allowed list.
$value string The value to compare against.
return Query The same instance of this class.

orderBy() public method

Sets the fields to order the results by. They should be in the the format 'fieldname ASC|DESC'. e.g 'dateAdded DESC'.
public orderBy ( mixed $fields ) : Query
$fields mixed An array comprising strings in the above format (or a single string)
return Query The same instance of this class.

where() public method

See also: Query::andWhere
public where ( $field, $operator = null, $value = null ) : Query
return Query The same instance of this class.

Property Details

$limit protected_oe property

protected $limit

$orderBy protected_oe property

protected $orderBy

$predicate protected_oe property

protected $predicate

$repo protected_oe property

protected $repo