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

T of object

implements

QueryInterface<T>

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

Table of Contents

Interfaces

QueryInterface
A persistence query interface

Constants

CHARSET  = 'utf-8'
Charset of strings in QOM
JCR_JOIN_TYPE_INNER  = '{http://www.jcp.org/jcr/1.0}joinTypeInner'
An inner join.
JCR_JOIN_TYPE_LEFT_OUTER  = '{http://www.jcp.org/jcr/1.0}joinTypeLeftOuter'
A left-outer join.
JCR_JOIN_TYPE_RIGHT_OUTER  = '{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>
$parentQuery  : QueryInterface|null
$persistenceManager  : PersistenceManagerInterface
$qomFactory  : QueryObjectModelFactory
$querySettings  : QuerySettingsInterface
The query settings.
$source  : SourceInterface
$statement  : Statement
$type  : string

Methods

__construct()  : mixed
__sleep()  : array<string|int, mixed>
__wakeup()  : mixed
between()  : AndInterface
Returns a greater than or equal criterion used for matching objects against a query
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()  : QueryResultInterface|array<int, array<string, mixed>>
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>
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()  : 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
The constraint used to limit the result set. Returns $this to allow for chaining (fluid interface)
setLimit()  : QueryInterface
Sets the maximum size of the result set to limit. Returns $this to allow for chaining (fluid interface)
setOffset()  : QueryInterface
Sets the start offset of the result set to offset. Returns $this to allow for chaining (fluid interface)
setOrderings()  : QueryInterface
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()  : mixed
Sets the source to fetch the result from
setType()  : void
Set the type this query cares for.
statement()  : QueryInterface
Sets the statement of this query. If you use this, you will lose the abstraction from a concrete storage backend (database).
unsetLimit()  : QueryInterface
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 mixed CHARSET = 'utf-8'

JCR_JOIN_TYPE_INNER

An inner join.

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

JCR_JOIN_TYPE_LEFT_OUTER

A left-outer join.

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

JCR_JOIN_TYPE_RIGHT_OUTER

A right-outer join.

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

Properties

$container

protected ContainerInterface $container

$orderings

protected array<string, string> $orderings = []

$type

protected string $type
Tags
phpstan-var

class-string<T>

Methods

__sleep()

public __sleep() : array<string|int, mixed>
Internal

only to be used within Extbase, not part of TYPO3 Core API.

Return values
array<string|int, mixed>

__wakeup()

public __wakeup() : mixed
Internal

only to be used within Extbase, not part of TYPO3 Core API.

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 ]) : QueryResultInterface|array<int, array<string, mixed>>
Parameters
$returnRawQueryResult : bool = false

avoids the object mapping by the persistence

Tags
phpstan-return

($returnRawQueryResult is true ? list<array<string,mixed>> : QueryResultInterface<int,T>)

Return values
QueryResultInterface|array<int, array<string, mixed>>

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>
Return values
array<string, string>

getType()

Returns the type this query cares for.

public getType() : string
Tags
phpstan-return

class-string<T>

Return values
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
Parameters
$limit : int
Tags
throws
InvalidArgumentException
phpstan-return

QueryInterface<T>

Return values
QueryInterface

setOffset()

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

public setOffset(int $offset) : QueryInterface
Parameters
$offset : int
Tags
throws
InvalidArgumentException
phpstan-return

QueryInterface<T>

Return values
QueryInterface

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<string|int, mixed> $orderings) : QueryInterface
Parameters
$orderings : array<string|int, mixed>

The property names to order by

Tags
phpstan-return

QueryInterface<T>

Return values
QueryInterface

setQuerySettings()

Sets the Query Settings. These Query settings must match the settings expected by the specific Storage Backend.

public setQuerySettings(QuerySettingsInterface $querySettings) : mixed
Parameters
$querySettings : QuerySettingsInterface

The Query Settings

setType()

Set the type this query cares for.

public setType(string $type) : void
Parameters
$type : string
Tags
phpstan-param

class-string<T> $type

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<string|int, mixed> $parameters = [] ]) : QueryInterface
Parameters
$statement : string|QueryBuilder|Statement

The statement

$parameters : array<string|int, mixed> = []

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

Return values
QueryInterface

unsetLimit()

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

public unsetLimit() : QueryInterface
Return values
QueryInterface

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

Search results