class Query implements QueryInterface (View source)

deprecated since Flow 6.0

The Query class used to run queries like $query->matching($query->equals('foo', 'bar'))->setLimit(10)->execute();

Properties

protected string $type
protected ClassSchema $classSchema
protected ObjectManagerInterface $objectManager
protected QueryObjectModelFactory $qomFactory
protected Constraint $constraint
protected array $orderings

The property names to order the result by. Expected like this: array( 'foo' => \Neos\Flow\Persistence\QueryInterface::ORDER_ASCENDING, 'bar' => \Neos\Flow\Persistence\QueryInterface::ORDER_DESCENDING )

protected int $limit
protected bool $distinct
protected int $offset

Methods

__construct(string $type, ReflectionService $reflectionService)

Constructs a query object working on the given type

void
injectObjectManager(ObjectManagerInterface $qomFactory)

Injects the Flow object factory

void
injectQomFactory(QueryObjectModelFactory $qomFactory)

Injects the Flow QOM factory

string
getType()

Returns the type this query cares for.

execute(bool $cacheResult = false)

Executes the query and returns the result

int
count()

Returns the query result count

setOrderings(array $orderings)

Sets the property names to order the result by. Expected like this: array( 'foo' => \Neos\Flow\Persistence\QueryInterface::ORDER_ASCENDING, 'bar' => \Neos\Flow\Persistence\QueryInterface::ORDER_DESCENDING )

array
getOrderings()

Returns the property names to order the result by, like this: array( 'foo' => \Neos\Flow\Persistence\QueryInterface::ORDER_ASCENDING, 'bar' => \Neos\Flow\Persistence\QueryInterface::ORDER_DESCENDING )

setLimit(int $limit)

Sets the maximum size of the result set to limit. Returns $this to allow for chaining (fluid interface)

getLimit()

Returns the maximum size of the result set to limit.

setDistinct(bool $distinct = true)

Sets the DISTINCT flag for this query.

bool
isDistinct()

Returns the DISTINCT flag for this query.

setOffset(int $offset)

Sets the start offset of the result set to $offset. Returns $this to allow for chaining (fluid interface)

int
getOffset()

Returns the start offset of the result set.

matching(object $constraint)

The constraint used to limit the result set. Returns $this to allow for chaining (fluid interface)

mixed
getConstraint()

Gets the constraint for this query.

object
logicalAnd(mixed $constraint1)

Performs a logical conjunction of the two given constraints. The method takes one or more contraints and concatenates them with a boolean AND.

object
logicalOr(mixed $constraint1)

Performs a logical disjunction of the two given constraints. The method takes one or more constraints and concatenates them with a boolean OR.

object
logicalNot(object $constraint)

Performs a logical negation of the given constraint

object
equals(string $propertyName, mixed $operand, bool $caseSensitive = true)

Returns an equals criterion used for matching objects against a query.

object
like(string $propertyName, string $operand, bool $caseSensitive = true)

Returns a like criterion used for matching objects against a query.

object
contains(string $propertyName, mixed $operand)

Returns a "contains" criterion used for matching objects against a query.

bool
isEmpty(string $propertyName)

Returns an "isEmpty" criterion used for matching objects against a query.

object
in(string $propertyName, mixed $operand)

Returns an "in" criterion used for matching objects against a query. It matches if the property's value is contained in the multivalued operand.

object
lessThan(string $propertyName, mixed $operand)

Returns a less than criterion used for matching objects against a query

object
lessThanOrEqual(string $propertyName, mixed $operand)

Returns a less or equal than criterion used for matching objects against a query

object
greaterThan(string $propertyName, mixed $operand)

Returns a greater than criterion used for matching objects against a query

object
greaterThanOrEqual(string $propertyName, mixed $operand)

Returns a greater than or equal criterion used for matching objects against a query

Details

__construct(string $type, ReflectionService $reflectionService)

Constructs a query object working on the given type

Parameters

string $type
ReflectionService $reflectionService

void injectObjectManager(ObjectManagerInterface $qomFactory)

Injects the Flow object factory

Parameters

ObjectManagerInterface $qomFactory

Return Value

void

void injectQomFactory(QueryObjectModelFactory $qomFactory)

Injects the Flow QOM factory

Parameters

QueryObjectModelFactory $qomFactory

Return Value

void

string getType()

Returns the type this query cares for.

Return Value

string

QueryResultInterface execute(bool $cacheResult = false)

Executes the query and returns the result

Parameters

bool $cacheResult

If the result cache should be used

Return Value

QueryResultInterface

The query result

int count()

Returns the query result count

Return Value

int

The query result count

QueryInterface setOrderings(array $orderings)

Sets the property names to order the result by. Expected like this: array( 'foo' => \Neos\Flow\Persistence\QueryInterface::ORDER_ASCENDING, 'bar' => \Neos\Flow\Persistence\QueryInterface::ORDER_DESCENDING )

Parameters

array $orderings

The property names to order by

Return Value

QueryInterface

array getOrderings()

Returns the property names to order the result by, like this: array( 'foo' => \Neos\Flow\Persistence\QueryInterface::ORDER_ASCENDING, 'bar' => \Neos\Flow\Persistence\QueryInterface::ORDER_DESCENDING )

Return Value

array

QueryInterface setLimit(int $limit)

Sets the maximum size of the result set to limit. Returns $this to allow for chaining (fluid interface)

Parameters

int $limit

Return Value

QueryInterface

Exceptions

InvalidArgumentException

getLimit()

Returns the maximum size of the result set to limit.

QueryInterface setDistinct(bool $distinct = true)

Sets the DISTINCT flag for this query.

Parameters

bool $distinct

Return Value

QueryInterface

bool isDistinct()

Returns the DISTINCT flag for this query.

Return Value

bool

QueryInterface setOffset(int $offset)

Sets the start offset of the result set to $offset. Returns $this to allow for chaining (fluid interface)

Parameters

int $offset

Return Value

QueryInterface

Exceptions

InvalidArgumentException

int getOffset()

Returns the start offset of the result set.

Return Value

int

QueryInterface matching(object $constraint)

The constraint used to limit the result set. Returns $this to allow for chaining (fluid interface)

Parameters

object $constraint

Some constraint, depending on the backend

Return Value

QueryInterface

mixed getConstraint()

Gets the constraint for this query.

Return Value

mixed

the constraint, or null if none

object logicalAnd(mixed $constraint1)

Performs a logical conjunction of the two given constraints. The method takes one or more contraints and concatenates them with a boolean AND.

It also accepts a single array of constraints to be concatenated.

Parameters

mixed $constraint1

The first of multiple constraints or an array of constraints.

Return Value

object

Exceptions

InvalidNumberOfConstraintsException

object logicalOr(mixed $constraint1)

Performs a logical disjunction of the two given constraints. The method takes one or more constraints and concatenates them with a boolean OR.

It also accepts a single array of constraints to be concatenated.

Parameters

mixed $constraint1

The first of multiple constraints or an array of constraints.

Return Value

object

Exceptions

InvalidNumberOfConstraintsException

object logicalNot(object $constraint)

Performs a logical negation of the given constraint

Parameters

object $constraint

Constraint to negate

Return Value

object

object equals(string $propertyName, mixed $operand, bool $caseSensitive = true)

Returns an equals criterion used for matching objects against a query.

It matches if the $operand equals the value of the property named $propertyName. If $operand is NULL a strict check for NULL is done. For strings the comparison can be done with or without case-sensitivity.

Decide what to do about equality on multi-valued properties

Parameters

string $propertyName

The name of the property to compare against

mixed $operand

The value to compare with

bool $caseSensitive

Whether the equality test should be done case-sensitive for strings

Return Value

object

object like(string $propertyName, string $operand, bool $caseSensitive = true)

Returns a like criterion used for matching objects against a query.

Matches if the property named $propertyName is like the $operand, using standard SQL wildcards.

Parameters

string $propertyName

The name of the property to compare against

string $operand

The value to compare with

bool $caseSensitive

Whether the matching should be done case-sensitive

Return Value

object

Exceptions

InvalidQueryException

object contains(string $propertyName, mixed $operand)

Returns a "contains" criterion used for matching objects against a query.

It matches if the multivalued property contains the given operand.

If NULL is given as $operand, there will never be a match!

Parameters

string $propertyName

The name of the multivalued property to compare against

mixed $operand

The value to compare with

Return Value

object

Exceptions

InvalidQueryException

bool isEmpty(string $propertyName)

Returns an "isEmpty" criterion used for matching objects against a query.

It matches if the multivalued property contains no values or is NULL.

Parameters

string $propertyName

The name of the multivalued property to compare against

Return Value

bool

Exceptions

InvalidQueryException

object in(string $propertyName, mixed $operand)

Returns an "in" criterion used for matching objects against a query. It matches if the property's value is contained in the multivalued operand.

Parameters

string $propertyName

The name of the property to compare against

mixed $operand

The value to compare with, multivalued

Return Value

object

Exceptions

InvalidQueryException

object lessThan(string $propertyName, mixed $operand)

Returns a less than criterion used for matching objects against a query

Parameters

string $propertyName

The name of the property to compare against

mixed $operand

The value to compare with

Return Value

object

Exceptions

InvalidQueryException

object lessThanOrEqual(string $propertyName, mixed $operand)

Returns a less or equal than criterion used for matching objects against a query

Parameters

string $propertyName

The name of the property to compare against

mixed $operand

The value to compare with

Return Value

object

Exceptions

InvalidQueryException

object greaterThan(string $propertyName, mixed $operand)

Returns a greater than criterion used for matching objects against a query

Parameters

string $propertyName

The name of the property to compare against

mixed $operand

The value to compare with

Return Value

object

Exceptions

InvalidQueryException

object greaterThanOrEqual(string $propertyName, mixed $operand)

Returns a greater than or equal criterion used for matching objects against a query

Parameters

string $propertyName

The name of the property to compare against

mixed $operand

The value to compare with

Return Value

object

Exceptions

InvalidQueryException