Query

class \TYPO3\CMS\Extbase\Persistence\Generic\Query

Implements
QueryInterface

The Query class used to run queries against the database

Tags

todo

v12: Candidate to declare final - Can be decorated or standalone class implementing the interface

template
implements

Attributes

#[Autoconfigure]
$public: true
$shared: false

Table of Contents

Interfaces

QueryInterface
A persistence query interface

Constants

CHARSET  : string = 'utf-8'
Charset of strings in QOM
JCR_JOIN_TYPE_INNER  : string = '{http://www.jcp.org/jcr/1.0}joinTypeInner'
An inner join.
JCR_JOIN_TYPE_LEFT_OUTER  : string = '{http://www.jcp.org/jcr/1.0}joinTypeLeftOuter'
A left-outer join.
JCR_JOIN_TYPE_RIGHT_OUTER  : string = '{http://www.jcp.org/jcr/1.0}joinTypeRightOuter'
A right-outer join.

Properties

$constraint  : ConstraintInterface
$container  : ContainerInterface
$dataMapFactory  : DataMapFactory
$limit  : int|null
$offset  : int
$orderings  : array<string, string>|OrderingInterface[]
$parentQuery  : QueryInterface|null
$persistenceManager  : PersistenceManagerInterface
$qomFactory  : QueryObjectModelFactory
$querySettings  : QuerySettingsInterface
$source  : SourceInterface|null
$statement  : Statement
$type  : class-string

Methods

__construct()  : mixed
__serialize()  : array
__unserialize()  : void
addOrderBy()  : QueryInterface<string|int, T>
Adds an ordering for the result. Appends to any existing orderings.
between()  : AndInterface
Returns a greater than or equal criterion used for matching objects against a query
coalesce()  : CoalesceInterface
Creates a COALESCE expression for ordering.
concat()  : ConcatInterface
Creates a CONCAT expression for ordering.
contains()  : ComparisonInterface
Returns a "contains" criterion used for matching objects against a query.
count()  : int
Returns the query result count.
equals()  : ComparisonInterface
Returns an equals criterion used for matching objects against a query
execute()  : ($returnRawQueryResult is true ? list> : QueryResultInterface)
Executes the query against the database and returns the result
getConstraint()  : ConstraintInterface|null
Gets the constraint for this query.
getLimit()  : int|null
Returns the maximum size of the result set to limit.
getOffset()  : int
Returns the start offset of the result set.
getOrderings()  : array<string, string>|OrderingInterface[]
Returns the property names to order the result by. Like this: array( 'foo' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING, 'bar' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_DESCENDING )
getParentQuery()  : QueryInterface|null
getQuerySettings()  : QuerySettingsInterface
Returns the Query Settings.
getSource()  : SourceInterface
Gets the node-tuple source for this query.
getStatement()  : Statement
Returns the statement of this query.
getType()  : class-string
Returns the type this query cares for.
greaterThan()  : ComparisonInterface
Returns a greater than criterion used for matching objects against a query
greaterThanOrEqual()  : ComparisonInterface
Returns a greater than or equal criterion used for matching objects against a query
in()  : ComparisonInterface
Returns an "in" criterion used for matching objects against a query. It matches if the property's value is contained in the multivalued operand.
lessThan()  : ComparisonInterface
Returns a less than criterion used for matching objects against a query
lessThanOrEqual()  : ComparisonInterface
Returns a less or equal than criterion used for matching objects against a query
like()  : ComparisonInterface
Returns a like criterion used for matching objects against a query
logicalAnd()  : AndInterface
Performs a logical conjunction of multiple given constraints. The method takes an arbitrary number of constraints and concatenates them with a boolean AND.
logicalNot()  : NotInterface
Performs a logical negation of the given constraint
logicalOr()  : OrInterface
Performs a logical disjunction of multiple given constraints. The method takes an arbitrary number of constraints and concatenates them with a boolean OR.
matching()  : QueryInterface<string|int, T>
The constraint used to limit the result set. Returns $this to allow for chaining (fluid interface)
orderBy()  : QueryInterface<string|int, T>
Sets the ordering for the result by a single operand. Replaces any existing orderings.
setLimit()  : QueryInterface<string|int, T>
Sets the maximum size of the result set to limit. Returns $this to allow for chaining (fluid interface)
setOffset()  : QueryInterface<string|int, T>
Sets the start offset of the result set to offset. Returns $this to allow for chaining (fluid interface)
setOrderings()  : QueryInterface<string|int, T>
Sets the property names to order the result by. Expected like this: array( 'foo' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING, 'bar' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_DESCENDING ) where 'foo' and 'bar' are property names.
setParentQuery()  : void
setQuerySettings()  : mixed
Sets the Query Settings. These Query settings must match the settings expected by the specific Storage Backend.
setSource()  : void
Sets the source to fetch the result from
setType()  : void
Set the type this query cares for.
statement()  : QueryInterface<string|int, T>
Sets the statement of this query. If you use this, you will lose the abstraction from a concrete storage backend (database).
trim()  : TrimInterface
Creates a TRIM expression for ordering.
unsetLimit()  : QueryInterface<string|int, T>
Resets a previously set maximum size of the result set. Returns $this to allow for chaining (fluid interface)
getSelectorName()  : string
Returns the selector's name or an empty string, if the source is not a selector

Constants

CHARSET

Charset of strings in QOM

public string CHARSET = 'utf-8'

JCR_JOIN_TYPE_INNER

An inner join.

public string JCR_JOIN_TYPE_INNER = '{http://www.jcp.org/jcr/1.0}joinTypeInner'

JCR_JOIN_TYPE_LEFT_OUTER

A left-outer join.

public string JCR_JOIN_TYPE_LEFT_OUTER = '{http://www.jcp.org/jcr/1.0}joinTypeLeftOuter'

JCR_JOIN_TYPE_RIGHT_OUTER

A right-outer join.

public string JCR_JOIN_TYPE_RIGHT_OUTER = '{http://www.jcp.org/jcr/1.0}joinTypeRightOuter'

Properties

$container

protected ContainerInterface $container

Methods

__serialize()

public __serialize() : array

Return values

array

__unserialize()

public __unserialize(array $data) : void

Parameters

$data : array

between()

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

public between(string $propertyName, mixed $operandLower, mixed $operandUpper) : AndInterface

Parameters

$propertyName : string

The name of the property to compare against

$operandLower : mixed

The value of the lower boundary to compare against

$operandUpper : mixed

The value of the upper boundary to compare against

Return values

AndInterface

contains()

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

public contains(string $propertyName, mixed $operand) : ComparisonInterface

It matches if the multivalued property contains the given operand.

Parameters

$propertyName : string

The name of the (multivalued) property to compare against

$operand : mixed

The value to compare with

Return values

ComparisonInterface

count()

Returns the query result count.

public count() : int

Return values

int —

The query result count

equals()

Returns an equals criterion used for matching objects against a query

public equals(string $propertyName, mixed $operand[, bool $caseSensitive = true ]) : ComparisonInterface

Parameters

$propertyName : string

The name of the property to compare against

$operand : mixed

The value to compare with

$caseSensitive : bool = true

Whether the equality test should be done case-sensitive

Return values

ComparisonInterface

execute()

Executes the query against the database and returns the result

public execute([bool $returnRawQueryResult = false ]) : ($returnRawQueryResult is true ? list> : QueryResultInterface)

Parameters

$returnRawQueryResult : bool = false

avoids the object mapping by the persistence

Return values

($returnRawQueryResult is true ? list> : QueryResultInterface) —

The query result object or an array if $returnRawQueryResult is TRUE

getLimit()

Returns the maximum size of the result set to limit.

public getLimit() : int|null

Return values

int|null

getOffset()

Returns the start offset of the result set.

public getOffset() : int

Return values

int

getOrderings()

Returns the property names to order the result by. Like this: array( 'foo' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING, 'bar' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_DESCENDING )

public getOrderings() : array<string, string>|OrderingInterface[]

Return values

array<string, string>|OrderingInterface[]

getType()

Returns the type this query cares for.

public getType() : class-string

Return values

class-string

greaterThan()

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

public greaterThan(string $propertyName, mixed $operand) : ComparisonInterface

Parameters

$propertyName : string

The name of the property to compare against

$operand : mixed

The value to compare with

Return values

ComparisonInterface

greaterThanOrEqual()

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

public greaterThanOrEqual(string $propertyName, mixed $operand) : ComparisonInterface

Parameters

$propertyName : string

The name of the property to compare against

$operand : mixed

The value to compare with

Return values

ComparisonInterface

in()

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

public in(string $propertyName, mixed $operand) : ComparisonInterface

Parameters

$propertyName : string

The name of the property to compare against

$operand : mixed

The value to compare with, multivalued

Tags

throws
UnexpectedTypeException

Return values

ComparisonInterface

lessThan()

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

public lessThan(string $propertyName, mixed $operand) : ComparisonInterface

Parameters

$propertyName : string

The name of the property to compare against

$operand : mixed

The value to compare with

Return values

ComparisonInterface

lessThanOrEqual()

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

public lessThanOrEqual(string $propertyName, mixed $operand) : ComparisonInterface

Parameters

$propertyName : string

The name of the property to compare against

$operand : mixed

The value to compare with

Return values

ComparisonInterface

like()

Returns a like criterion used for matching objects against a query

public like(string $propertyName, mixed $operand) : ComparisonInterface

Parameters

$propertyName : string

The name of the property to compare against

$operand : mixed

The value to compare with

Return values

ComparisonInterface

setLimit()

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

public setLimit(int $limit) : QueryInterface<string|int, T>

Parameters

$limit : int

Tags

throws
InvalidArgumentException

Return values

QueryInterface<string|int, T>

setOffset()

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

public setOffset(int $offset) : QueryInterface<string|int, T>

Parameters

$offset : int

Tags

throws
InvalidArgumentException

Return values

QueryInterface<string|int, T>

setOrderings()

Sets the property names to order the result by. Expected like this: array( 'foo' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING, 'bar' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_DESCENDING ) where 'foo' and 'bar' are property names.

public setOrderings(array $orderings) : QueryInterface<string|int, T>

Parameters

$orderings : array

The property names to order by

Return values

QueryInterface<string|int, T>

setType()

Set the type this query cares for.

public setType(class-string $type) : void

Parameters

$type : class-string

statement()

Sets the statement of this query. If you use this, you will lose the abstraction from a concrete storage backend (database).

public statement(string|QueryBuilder|Statement $statement[, array $parameters = [] ]) : QueryInterface<string|int, T>

Parameters

$statement : string|QueryBuilder|Statement

The statement

$parameters : array = []

An array of parameters. These will be bound to placeholders '?' in the $statement.

Return values

QueryInterface<string|int, T>

unsetLimit()

Resets a previously set maximum size of the result set. Returns $this to allow for chaining (fluid interface)

public unsetLimit() : QueryInterface<string|int, T>

Return values

QueryInterface<string|int, T>

getSelectorName()

Returns the selector's name or an empty string, if the source is not a selector

protected getSelectorName() : string

Tags

todo

This has to be checked at another place

Return values

string —

The selector name

On this page