TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
Query Class Reference
Inheritance diagram for Query:
QueryInterface

Public Member Functions

 injectObjectManager (\TYPO3\CMS\Extbase\Object\ObjectManagerInterface $objectManager)
 
 injectDataMapper (\TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper $dataMapper)
 
 injectPersistenceManager (\TYPO3\CMS\Extbase\Persistence\PersistenceManagerInterface $persistenceManager)
 
 injectQomFactory (\TYPO3\CMS\Extbase\Persistence\Generic\Qom\QueryObjectModelFactory $qomFactory)
 
 __construct ($type)
 
 setQuerySettings (QuerySettingsInterface $querySettings)
 
 getQuerySettings ()
 
 getType ()
 
 setSource (\TYPO3\CMS\Extbase\Persistence\Generic\Qom\SourceInterface $source)
 
 getSource ()
 
 execute ($returnRawQueryResult=false)
 
 setOrderings (array $orderings)
 
 getOrderings ()
 
 setLimit ($limit)
 
 unsetLimit ()
 
 getLimit ()
 
 setOffset ($offset)
 
 getOffset ()
 
 matching ($constraint)
 
 statement ($statement, array $parameters=[])
 
 getStatement ()
 
 getConstraint ()
 
 logicalAnd ($constraint1)
 
 logicalOr ($constraint1)
 
 logicalNot (\TYPO3\CMS\Extbase\Persistence\Generic\Qom\ConstraintInterface $constraint)
 
 equals ($propertyName, $operand, $caseSensitive=true)
 
 like ($propertyName, $operand, $caseSensitive=null)
 
 contains ($propertyName, $operand)
 
 in ($propertyName, $operand)
 
 lessThan ($propertyName, $operand)
 
 lessThanOrEqual ($propertyName, $operand)
 
 greaterThan ($propertyName, $operand)
 
 greaterThanOrEqual ($propertyName, $operand)
 
 between ($propertyName, $operandLower, $operandUpper)
 
 __wakeup ()
 
 __sleep ()
 
 count ()
 
 isEmpty ($propertyName)
 
- Public Member Functions inherited from QueryInterface
 logicalNot (ConstraintInterface $constraint)
 
 setQuerySettings (Generic\QuerySettingsInterface $querySettings)
 
 setSource (Generic\Qom\SourceInterface $source)
 

Public Attributes

const JCR_JOIN_TYPE_INNER = '{http://www.jcp.org/jcr/1.0}joinTypeInner'
 
const JCR_JOIN_TYPE_LEFT_OUTER = '{http://www.jcp.org/jcr/1.0}joinTypeLeftOuter'
 
const JCR_JOIN_TYPE_RIGHT_OUTER = '{http://www.jcp.org/jcr/1.0}joinTypeRightOuter'
 
const CHARSET = 'utf-8'
 
- Public Attributes inherited from QueryInterface
const OPERATOR_EQUAL_TO = 1
 
const OPERATOR_EQUAL_TO_NULL = 101
 
const OPERATOR_NOT_EQUAL_TO = 2
 
const OPERATOR_NOT_EQUAL_TO_NULL = 202
 
const OPERATOR_LESS_THAN = 3
 
const OPERATOR_LESS_THAN_OR_EQUAL_TO = 4
 
const OPERATOR_GREATER_THAN = 5
 
const OPERATOR_GREATER_THAN_OR_EQUAL_TO = 6
 
const OPERATOR_LIKE = 7
 
const OPERATOR_CONTAINS = 8
 
const OPERATOR_IN = 9
 
const OPERATOR_IS_NULL = 10
 
const OPERATOR_IS_EMPTY = 11
 
const ORDER_ASCENDING = 'ASC'
 
const ORDER_DESCENDING = 'DESC'
 

Protected Member Functions

 getSelectorName ()
 

Protected Attributes

 $type
 
 $objectManager
 
 $dataMapper
 
 $persistenceManager
 
 $qomFactory
 
 $source
 
 $constraint
 
 $statement
 
 $orderings = []
 
 $limit
 
 $offset
 
 $querySettings
 

Detailed Description

The Query class used to run queries against the database

Definition at line 25 of file Query.php.

Constructor & Destructor Documentation

__construct (   $type)

Constructs a query object working on the given class name

Parameters
string$type

Definition at line 147 of file Query.php.

References Query\$type.

Member Function Documentation

__sleep ( )
Returns
array

Definition at line 635 of file Query.php.

__wakeup ( )
Returns
void

Definition at line 624 of file Query.php.

References GeneralUtility\makeInstance().

between (   $propertyName,
  $operandLower,
  $operandUpper 
)

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

Parameters
string$propertyNameThe name of the property to compare against
$operandLowerThe value of the lower boundary to compare against
$operandUpperThe value of the upper boundary to compare against
Returns
Exceptions
TYPO3

Definition at line 613 of file Query.php.

References Query\greaterThanOrEqual(), Query\lessThanOrEqual(), and Query\logicalAnd().

contains (   $propertyName,
  $operand 
)

Returns a "contains" criterion used for matching objects against a query. It matches if the multivalued property contains the given operand.

Parameters
string$propertyNameThe name of the (multivalued) property to compare against
mixed$operandThe value to compare with
Returns

Implements QueryInterface.

Definition at line 528 of file Query.php.

References QueryInterface\OPERATOR_CONTAINS.

count ( )

Returns the query result count.

Returns
int The query result count

Implements QueryInterface.

Definition at line 646 of file Query.php.

References Query\execute().

equals (   $propertyName,
  $operand,
  $caseSensitive = true 
)

Returns an equals criterion used for matching objects against a query

Parameters
string$propertyNameThe name of the property to compare against
mixed$operandThe value to compare with
bool$caseSensitiveWhether the equality test should be done case-sensitive
Returns

Implements QueryInterface.

Definition at line 474 of file Query.php.

References Query\CHARSET, and QueryInterface\OPERATOR_EQUAL_TO.

execute (   $returnRawQueryResult = false)

Executes the query against the database and returns the result

Parameters
bool$returnRawQueryResultavoids the object mapping by the persistence
Returns
|array The query result object or an array if $returnRawQueryResult is TRUE

Implements QueryInterface.

Definition at line 237 of file Query.php.

Referenced by Query\count().

getConstraint ( )

Gets the constraint for this query.

Returns
|NULL the constraint, or null if none

Implements QueryInterface.

Definition at line 394 of file Query.php.

References Query\$constraint.

getLimit ( )

Returns the maximum size of the result set to limit.

Returns
int

Implements QueryInterface.

Definition at line 316 of file Query.php.

References Query\$limit.

getOffset ( )

Returns the start offset of the result set.

Returns
int

Implements QueryInterface.

Definition at line 345 of file Query.php.

References Query\$offset.

getOrderings ( )

Returns the property names to order the result by. Like this: array( 'foo' => ::ORDER_ASCENDING, 'bar' => ::ORDER_DESCENDING )

Returns
array

Implements QueryInterface.

Definition at line 274 of file Query.php.

References Query\$orderings.

getQuerySettings ( )

Returns the Query Settings.

Exceptions
Exception
Returns
QuerySettingsInterface $querySettings The Query Settings This method is not part of TYPO3.Flow API

Implements QueryInterface.

Definition at line 172 of file Query.php.

References Query\$querySettings.

getSelectorName ( )
protected

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

Todo:
This has to be checked at another place
Returns
string The selector name

Definition at line 207 of file Query.php.

References Query\$source, and Query\getSource().

getSource ( )

Gets the node-tuple source for this query.

Returns
the node-tuple source; non-null

Implements QueryInterface.

Definition at line 222 of file Query.php.

References Query\$source, and Query\getType().

Referenced by Query\getSelectorName().

getStatement ( )

Returns the statement of this query.

Returns

Implements QueryInterface.

Definition at line 383 of file Query.php.

References Query\$statement.

getType ( )

Returns the type this query cares for.

Returns
string

Implements QueryInterface.

Definition at line 186 of file Query.php.

References Query\$type.

Referenced by Query\getSource().

greaterThan (   $propertyName,
  $operand 
)

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

Parameters
string$propertyNameThe name of the property to compare against
mixed$operandThe value to compare with
Returns

Implements QueryInterface.

Definition at line 585 of file Query.php.

References QueryInterface\OPERATOR_GREATER_THAN.

greaterThanOrEqual (   $propertyName,
  $operand 
)

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

Parameters
string$propertyNameThe name of the property to compare against
mixed$operandThe value to compare with
Returns

Implements QueryInterface.

Definition at line 598 of file Query.php.

References QueryInterface\OPERATOR_GREATER_THAN_OR_EQUAL_TO.

Referenced by Query\between().

in (   $propertyName,
  $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$propertyNameThe name of the property to compare against
mixed$operandThe value to compare with, multivalued
Exceptions
ExceptionUnexpectedTypeException
Returns

Implements QueryInterface.

Definition at line 543 of file Query.php.

References QueryInterface\OPERATOR_IN.

injectDataMapper ( \TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper  $dataMapper)
Parameters
\TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper$dataMapper

Definition at line 121 of file Query.php.

References Query\$dataMapper.

injectObjectManager ( \TYPO3\CMS\Extbase\Object\ObjectManagerInterface  $objectManager)
Parameters
\TYPO3\CMS\Extbase\Object\ObjectManagerInterface$objectManager

Definition at line 113 of file Query.php.

References Query\$objectManager.

injectPersistenceManager ( \TYPO3\CMS\Extbase\Persistence\PersistenceManagerInterface  $persistenceManager)
Parameters
\TYPO3\CMS\Extbase\Persistence\PersistenceManagerInterface$persistenceManager

Definition at line 129 of file Query.php.

References Query\$persistenceManager.

Parameters
\TYPO3\CMS\Extbase\Persistence\Generic\Qom\QueryObjectModelFactory$qomFactory

Definition at line 137 of file Query.php.

References Query\$qomFactory.

isEmpty (   $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$propertyNameThe name of the multivalued property to compare against
Exceptions
TYPO3
TYPO3 if used on a single-valued property
Returns
bool

Implements QueryInterface.

Definition at line 661 of file Query.php.

lessThan (   $propertyName,
  $operand 
)

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

Parameters
string$propertyNameThe name of the property to compare against
mixed$operandThe value to compare with
Returns

Implements QueryInterface.

Definition at line 559 of file Query.php.

References QueryInterface\OPERATOR_LESS_THAN.

lessThanOrEqual (   $propertyName,
  $operand 
)

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

Parameters
string$propertyNameThe name of the property to compare against
mixed$operandThe value to compare with
Returns

Implements QueryInterface.

Definition at line 572 of file Query.php.

References QueryInterface\OPERATOR_LESS_THAN_OR_EQUAL_TO.

Referenced by Query\between().

like (   $propertyName,
  $operand,
  $caseSensitive = null 
)

Returns a like criterion used for matching objects against a query

Parameters
string$propertyNameThe name of the property to compare against
mixed$operandThe value to compare with
bool$caseSensitive,deprecatedsince TYPO3 v8, will be removed in TYPO3 v9
Returns

Implements QueryInterface.

Definition at line 501 of file Query.php.

References GeneralUtility\deprecationLog(), and QueryInterface\OPERATOR_LIKE.

logicalAnd (   $constraint1)

Performs a logical conjunction of the given constraints. The method takes one or more constraints and concatenates them with a boolean AND. It also accepts a single array of constraints to be concatenated.

Parameters
mixed$constraint1The first of multiple constraints or an array of constraints.
Exceptions
ExceptionInvalidNumberOfConstraintsException
Returns

Implements QueryInterface.

Definition at line 408 of file Query.php.

References Query\$constraint.

Referenced by Query\between().

Performs a logical negation of the given constraint

Parameters
\TYPO3\CMS\Extbase\Persistence\Generic\Qom\ConstraintInterface$constraintConstraint to negate
Exceptions
RuntimeException
Returns

Definition at line 460 of file Query.php.

logicalOr (   $constraint1)

Performs a logical disjunction of the two given constraints

Parameters
mixed$constraint1The first of multiple constraints or an array of constraints.
Exceptions
ExceptionInvalidNumberOfConstraintsException
Returns

Implements QueryInterface.

Definition at line 434 of file Query.php.

References Query\$constraint.

matching (   $constraint)

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

Parameters
\TYPO3\CMS\Extbase\Persistence\Generic\Qom\ConstraintInterface$constraint
Returns
QueryInterface

Implements QueryInterface.

Definition at line 358 of file Query.php.

References Query\$constraint.

setLimit (   $limit)

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

Parameters
int$limit
Exceptions
InvalidArgumentException
Returns
QueryInterface

Implements QueryInterface.

Definition at line 288 of file Query.php.

References Query\$limit.

setOffset (   $offset)

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

Parameters
int$offset
Exceptions
InvalidArgumentException
Returns
QueryInterface

Implements QueryInterface.

Definition at line 330 of file Query.php.

References Query\$offset.

setOrderings ( array  $orderings)

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

Parameters
array$orderingsThe property names to order by
Returns
QueryInterface

Implements QueryInterface.

Definition at line 258 of file Query.php.

References Query\$orderings.

setQuerySettings ( QuerySettingsInterface  $querySettings)

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

Parameters
QuerySettingsInterface$querySettingsThe Query Settings
Returns
void This method is not part of TYPO3.Flow API

Definition at line 160 of file Query.php.

References Query\$querySettings.

Sets the source to fetch the result from

Parameters
\TYPO3\CMS\Extbase\Persistence\Generic\Qom\SourceInterface$source

Definition at line 196 of file Query.php.

References Query\$source.

statement (   $statement,
array  $parameters = [] 
)

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

Parameters
string | \TYPO3\CMS\Core\Database\PreparedStatement | \TYPO3\CMS\Core\Database\Query\QueryBuilder | \Doctrine\DBAL\Statement$statementThe statement
array$parametersAn array of parameters. These will be bound to placeholders '?' in the $statement.
Returns
QueryInterface

Definition at line 372 of file Query.php.

References Query\$statement.

unsetLimit ( )

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

Returns
QueryInterface

Definition at line 304 of file Query.php.

Member Data Documentation

$constraint
protected

Definition at line 81 of file Query.php.

Referenced by Query\getConstraint(), Query\logicalAnd(), Query\logicalOr(), and Query\matching().

$dataMapper
protected

Definition at line 60 of file Query.php.

Referenced by Query\injectDataMapper().

$limit
protected

Definition at line 96 of file Query.php.

Referenced by Query\getLimit(), and Query\setLimit().

$objectManager
protected

Definition at line 55 of file Query.php.

Referenced by Query\injectObjectManager().

$offset
protected

Definition at line 101 of file Query.php.

Referenced by Query\getOffset(), and Query\setOffset().

$orderings = []
protected

Definition at line 91 of file Query.php.

Referenced by Query\getOrderings(), and Query\setOrderings().

$persistenceManager
protected

Definition at line 66 of file Query.php.

Referenced by Query\injectPersistenceManager().

$qomFactory
protected

Definition at line 71 of file Query.php.

Referenced by Query\injectQomFactory().

$querySettings
protected

Definition at line 108 of file Query.php.

Referenced by Query\getQuerySettings(), and Query\setQuerySettings().

$source
protected

Definition at line 76 of file Query.php.

Referenced by Query\getSelectorName(), Query\getSource(), and Query\setSource().

$statement
protected

Definition at line 86 of file Query.php.

Referenced by Query\getStatement(), and Query\statement().

$type
protected

Definition at line 50 of file Query.php.

Referenced by Query\__construct(), and Query\getType().

const CHARSET = 'utf-8'

Charset of strings in QOM

Definition at line 45 of file Query.php.

Referenced by Query\equals().

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

An inner join.

Definition at line 30 of file Query.php.

Referenced by DataMapper\getSource().

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

A left-outer join.

Definition at line 35 of file Query.php.

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

A right-outer join.

Definition at line 40 of file Query.php.