Craft 3 Class Reference

Interface craft\elements\db\ElementQueryInterface

Extends
ArrayAccess, Countable, IteratorAggregate, yii\base\Arrayable, yii\db\QueryInterface
Implemented by
craft\elements\db\AssetQuery, craft\elements\db\CategoryQuery, craft\elements\db\ElementQuery, craft\elements\db\EntryQuery, craft\elements\db\GlobalSetQuery, craft\elements\db\MatrixBlockQuery, craft\elements\db\TagQuery, craft\elements\db\UserQuery
Available since version
3.0
Source Code
https://github.com/craftcms/cms/blob/master/src/elements/db/ElementQueryInterface.php

ElementQueryInterface defines the common interface to be implemented by element query classes.

The default implementation of this interface is provided by craft\elements\db\ElementQuery.

Public Methods
Method Description Defined By
addOrderBy() Adds additional ORDER BY columns to the query. yii\db\QueryInterface
all() Executes the query and returns all results as an array. craft\elements\db\ElementQueryInterface
ancestorDist() Sets the ancestorDist() property. craft\elements\db\ElementQueryInterface
ancestorOf() Sets the ancestorOf() property. craft\elements\db\ElementQueryInterface
andFilterWhere() Adds an additional WHERE condition to the existing one ignoring empty parameters. yii\db\QueryInterface
andWhere() Adds an additional WHERE condition to the existing one. yii\db\QueryInterface
archived() Sets the archived() property. craft\elements\db\ElementQueryInterface
asArray() Sets the asArray() property. craft\elements\db\ElementQueryInterface
count() Returns the number of records. yii\db\QueryInterface
dateCreated() Sets the dateCreated() property. craft\elements\db\ElementQueryInterface
dateUpdated() Sets the dateUpdated() property. craft\elements\db\ElementQueryInterface
descendantDist() Sets the descendantDist() property. craft\elements\db\ElementQueryInterface
descendantOf() Sets the descendantOf() property. craft\elements\db\ElementQueryInterface
emulateExecution() Sets whether to emulate query execution, preventing any interaction with data storage. yii\db\QueryInterface
enabledForSite() Sets the enabledForSite() property. craft\elements\db\ElementQueryInterface
exists() Returns a value indicating whether the query result contains any row of data. yii\db\QueryInterface
extraFields() Returns the list of additional fields that can be returned by toArray() in addition to those listed in fields(). yii\base\Arrayable
fields() Returns the list of fields that should be returned by default by toArray() when no specific fields are specified. yii\base\Arrayable
filterWhere() Sets the WHERE part of the query ignoring empty parameters. yii\db\QueryInterface
fixedOrder() Sets the fixedOrder() property. craft\elements\db\ElementQueryInterface
id() Sets the id() property. craft\elements\db\ElementQueryInterface
ids() Executes the query and returns the IDs of the resulting elements. craft\elements\db\ElementQueryInterface
indexBy() Sets the indexBy() property. yii\db\QueryInterface
level() Sets the level() property. craft\elements\db\ElementQueryInterface
limit() Sets the LIMIT part of the query. yii\db\QueryInterface
nextSiblingOf() Sets the nextSiblingOf() property. craft\elements\db\ElementQueryInterface
nth() Executes the query and returns a single row of result at a given offset. craft\elements\db\ElementQueryInterface
offset() Sets the OFFSET part of the query. yii\db\QueryInterface
one() Executes the query and returns a single row of result. craft\elements\db\ElementQueryInterface
orFilterWhere() Adds an additional WHERE condition to the existing one ignoring empty parameters. yii\db\QueryInterface
orWhere() Adds an additional WHERE condition to the existing one. yii\db\QueryInterface
orderBy() Sets the ORDER BY part of the query. yii\db\QueryInterface
positionedAfter() Sets the positionedAfter() property. craft\elements\db\ElementQueryInterface
positionedBefore() Sets the positionedBefore() property. craft\elements\db\ElementQueryInterface
prevSiblingOf() Sets the prevSiblingOf() property. craft\elements\db\ElementQueryInterface
ref() Sets the ref() property. craft\elements\db\ElementQueryInterface
relatedTo() Sets the relatedTo() property. craft\elements\db\ElementQueryInterface
search() Sets the search() property. craft\elements\db\ElementQueryInterface
siblingOf() Sets the siblingOf() property. craft\elements\db\ElementQueryInterface
site() Sets the siteId() property based on a given site(s)’s handle. craft\elements\db\ElementQueryInterface
siteId() Sets the siteId() property. craft\elements\db\ElementQueryInterface
slug() Sets the slug() property. craft\elements\db\ElementQueryInterface
status() Sets the status() property. craft\elements\db\ElementQueryInterface
structureId() Sets the structureId() property. craft\elements\db\ElementQueryInterface
title() Sets the title() property. craft\elements\db\ElementQueryInterface
toArray() Converts the object into an array. yii\base\Arrayable
uid() Sets the uid() property. craft\elements\db\ElementQueryInterface
uri() Sets the uri() property. craft\elements\db\ElementQueryInterface
where() Sets the WHERE part of the query. yii\db\QueryInterface
with() Sets the with() property. craft\elements\db\ElementQueryInterface
withStructure() Sets the withStructure() property. craft\elements\db\ElementQueryInterface

Method Details

all() public abstract method #

Executes the query and returns all results as an array.

public abstract craft\base\ElementInterface[] all ( $db null )
$db yii\db\Connection, null The database connection used to generate the SQL statement. If this parameter is not given, the db application component will be used.
return craft\base\ElementInterface[] The resulting elements.

ancestorDist() public abstract method #

Sets the ancestorDist() property.

public abstract static ancestorDist ( \craft\elements\db\int $value null )
$value integer, null The property value
return static Self reference

ancestorOf() public abstract method #

Sets the ancestorOf() property.

public abstract static ancestorOf ( $value )
$value integer, craft\base\ElementInterface, null The property value
return static Self reference

archived() public abstract method #

Sets the archived() property.

public abstract static archived ( \craft\elements\db\bool $value true )
$value boolean The property value (defaults to true)
return static Self reference

asArray() public abstract method #

Sets the asArray() property.

public abstract static asArray ( \craft\elements\db\bool $value true )
$value boolean The property value (defaults to true)
return static Self reference

dateCreated() public abstract method #

Sets the dateCreated() property.

public abstract static dateCreated ( $value )
$value mixed The property value
return static Self reference

dateUpdated() public abstract method #

Sets the dateUpdated() property.

public abstract static dateUpdated ( $value )
$value mixed The property value
return static Self reference

descendantDist() public abstract method #

Sets the descendantDist() property.

public abstract static descendantDist ( \craft\elements\db\int $value null )
$value integer, null The property value
return static Self reference

descendantOf() public abstract method #

Sets the descendantOf() property.

public abstract static descendantOf ( $value )
$value integer, craft\base\ElementInterface, null The property value
return static Self reference

enabledForSite() public abstract method #

Sets the enabledForSite() property.

public abstract static enabledForSite ( \craft\elements\db\bool $value true )
$value boolean The property value (defaults to true)
return static Self reference

fixedOrder() public abstract method #

Sets the fixedOrder() property.

public abstract static fixedOrder ( \craft\elements\db\bool $value true )
$value boolean The property value (defaults to true)
return static Self reference

id() public abstract method #

Sets the id() property.

public abstract static id ( $value )
$value integer, integer[], false, null The property value
return static Self reference

ids() public abstract method #

Executes the query and returns the IDs of the resulting elements.

public abstract integer[] ids ( $db null )
$db yii\db\Connection, null The database connection used to generate the SQL statement. If this parameter is not given, the db application component will be used.
return integer[] The resulting element IDs. An empty array is returned if no elements are found.

level() public abstract method #

Sets the level() property.

public abstract static level ( $value null )
$value mixed The property value
return static Self reference

nextSiblingOf() public abstract method #

Sets the nextSiblingOf() property.

public abstract static nextSiblingOf ( $value )
$value integer, craft\base\ElementInterface, null The property value
return static Self reference

nth() public abstract method #

Executes the query and returns a single row of result at a given offset.

public abstract craft\base\ElementInterface, array, null nth ( \craft\elements\db\int $n, yii\db\Connection $db null )
$n integer The offset of the row to return. If offset() is set, $offset will be added to it.
$db yii\db\Connection, null The database connection used to generate the SQL statement. If this parameter is not given, the db application component will be used.
return craft\base\ElementInterface, array, null The element or row of the query result. Null is returned if the query results in nothing.

one() public abstract method #

Executes the query and returns a single row of result.

public abstract craft\base\ElementInterface, array, null one ( $db null )
$db yii\db\Connection The database connection used to execute the query. If this parameter is not given, the db application component will be used.
return craft\base\ElementInterface, array, null The resulting element. Null is returned if the query results in nothing.

positionedAfter() public abstract method #

Sets the positionedAfter() property.

public abstract static positionedAfter ( $value )
$value integer, craft\base\ElementInterface, null The property value
return static Self reference

positionedBefore() public abstract method #

Sets the positionedBefore() property.

public abstract static positionedBefore ( $value )
$value integer, craft\base\ElementInterface, null The property value
return static Self reference

prevSiblingOf() public abstract method #

Sets the prevSiblingOf() property.

public abstract static prevSiblingOf ( $value )
$value integer, craft\base\ElementInterface, null The property value
return static Self reference

ref() public abstract method #

Sets the ref() property.

public abstract static ref ( $value )
$value string, string[], null The property value
return static Self reference

relatedTo() public abstract method #

Sets the relatedTo() property.

public abstract static relatedTo ( $value )
$value integer, array, craft\base\ElementInterface, null The property value
return static Self reference

search() public abstract method #

Sets the search() property.

public abstract static search ( $value )
$value string, array, craft\search\SearchQuery, null The property value
return static Self reference

siblingOf() public abstract method #

Sets the siblingOf() property.

public abstract static siblingOf ( $value )
$value integer, craft\base\ElementInterface, null The property value
return static Self reference

site() public abstract method #

Sets the siteId() property based on a given site(s)’s handle.

public abstract static site ( $value )
$value string, craft\models\Site The property value
return static Self reference

siteId() public abstract method #

Sets the siteId() property.

public abstract static siteId ( \craft\elements\db\int $value null )
$value integer, null The property value
return static Self reference

slug() public abstract method #

Sets the slug() property.

public abstract static slug ( $value )
$value string, string[], null The property value
return static Self reference

status() public abstract method #

Sets the status() property.

public abstract static status ( $value )
$value string, string[], null The property value
return static Self reference

structureId() public abstract method #

Sets the structureId() property.

public abstract static structureId ( \craft\elements\db\int $value null )
$value integer, null The property value
return static Self reference

title() public abstract method #

Sets the title() property.

public abstract static title ( $value )
$value string, string[], null The property value
return static Self reference

uid() public abstract method #

Sets the uid() property.

public abstract static uid ( $value )
$value string, string[], null The property value
return static Self reference

uri() public abstract method #

Sets the uri() property.

public abstract static uri ( $value )
$value string, string[], null The property value
return static Self reference

with() public abstract method #

Sets the with() property.

public abstract self with ( $value )
$value string, array, null The property value
return self The query object itself

withStructure() public abstract method #

Sets the withStructure() property.

public abstract static withStructure ( \craft\elements\db\bool $value true )
$value boolean The property value (defaults to true)
return static Self reference