Craft 3 Class Reference

Class craft\elements\db\GlobalSetQuery

Inheritance
craft\elements\db\GlobalSetQuery » craft\elements\db\ElementQuery » craft\db\Query » yii\db\Query » yii\base\Component » yii\base\BaseObject
Implements
craft\elements\db\ElementQueryInterface, yii\base\Configurable, yii\db\ExpressionInterface, yii\db\QueryInterface
Uses Traits
yii\base\ArrayableTrait, yii\db\QueryTrait
Available since version
3.0
Source Code
https://github.com/craftcms/cms/blob/master/src/elements/db/GlobalSetQuery.php

GlobalSetQuery represents a SELECT SQL statement for global sets in a way that is independent of DBMS.

Public Properties
Property Type Description Defined By
$ancestorDist integer, null The maximum number of levels that results may be separated from ancestorOf(). craft\elements\db\ElementQuery
$ancestorOf integer, craft\base\ElementInterface, null The element (or its ID) that results must be an ancestor of. craft\elements\db\ElementQuery
$archived boolean Whether to return only archived elements. craft\elements\db\ElementQuery
$asArray boolean Whether to return each element as an array. craft\elements\db\ElementQuery
$contentTable string, null The content table that will be joined by this query. craft\elements\db\ElementQuery
$customFields craft\base\FieldInterface[], null The fields that may be involved in this query. craft\elements\db\ElementQuery
$dateCreated mixed When the resulting elements must have been created. craft\elements\db\ElementQuery
$dateUpdated mixed When the resulting elements must have been last updated. craft\elements\db\ElementQuery
$descendantDist integer, null The maximum number of levels that results may be separated from descendantOf(). craft\elements\db\ElementQuery
$descendantOf integer, craft\base\ElementInterface, null The element (or its ID) that results must be a descendant of. craft\elements\db\ElementQuery
$distinct boolean Whether to select distinct rows of data only. yii\db\Query
$editable boolean Whether to only return global sets that the user has permission to edit. craft\elements\db\GlobalSetQuery
$elementType string, null The name of the craft\base\ElementInterface class. craft\elements\db\ElementQuery
$emulateExecution boolean Whether to emulate the actual query execution, returning empty or false results. yii\db\QueryTrait
$enabledForSite boolean Whether the elements must be enabled for the chosen site. craft\elements\db\ElementQuery
$fixedOrder boolean Whether results should be returned in the order specified by id(). craft\elements\db\ElementQuery
$from array The table(s) to be selected from. yii\db\Query
$groupBy array How to group the query results. yii\db\Query
$handle string, string[], null The handle(s) that the resulting global sets must have. craft\elements\db\GlobalSetQuery
$having string, array, yii\db\ExpressionInterface The condition to be applied in the GROUP BY clause. yii\db\Query
$id integer, integer[], false, null The element ID(s). craft\elements\db\ElementQuery
$inReverse boolean Whether the results should be queried in reverse. craft\elements\db\ElementQuery
$indexBy string, callable The name of the column by which the query results should be indexed by. yii\db\QueryTrait
$join array How to join with other tables. yii\db\Query
$level mixed The element’s level within the structure craft\elements\db\ElementQuery
$limit integer, yii\db\ExpressionInterface Maximum number of records to be returned. yii\db\QueryTrait
$nextSiblingOf integer, craft\base\ElementInterface, null The element (or its ID) that the result must be the next sibling of. craft\elements\db\ElementQuery
$offset integer, yii\db\ExpressionInterface Zero-based offset from where the records are to be returned. yii\db\QueryTrait
$orderBy array How to sort the query results. yii\db\QueryTrait
$params array List of query parameter values indexed by parameter placeholders. yii\db\Query
$positionedAfter integer, craft\base\ElementInterface, null The element (or its ID) that the results must be positioned after. craft\elements\db\ElementQuery
$positionedBefore integer, craft\base\ElementInterface, null The element (or its ID) that the results must be positioned before. craft\elements\db\ElementQuery
$prevSiblingOf integer, craft\base\ElementInterface, null The element (or its ID) that the result must be the previous sibling of. craft\elements\db\ElementQuery
$query craft\db\Query, null The query object created by prepare() craft\elements\db\ElementQuery
$queryCacheDependency yii\caching\Dependency The dependency to be associated with the cached query result for this query yii\db\Query
$queryCacheDuration integer, true The default number of seconds that query results can remain valid in cache. yii\db\Query
$ref string, string[], null The reference code(s) used to identify the element(s). craft\elements\db\ElementQuery
$relatedTo integer, array, craft\base\ElementInterface, null The element relation criteria. craft\elements\db\ElementQuery
$search string, array, craft\search\SearchQuery, null The search term to filter the resulting elements by. craft\elements\db\ElementQuery
$select array The columns being selected. yii\db\Query
$selectOption string Additional option that should be appended to the 'SELECT' keyword. yii\db\Query
$siblingOf integer, craft\base\ElementInterface, null The element (or its ID) that the results must be a sibling of. craft\elements\db\ElementQuery
$siteId integer, null The site ID that the elements should be returned in. craft\elements\db\ElementQuery
$slug string, string[], null The slug that resulting elements must have. craft\elements\db\ElementQuery
$status string, string[], null The status(es) that the resulting elements must have. craft\elements\db\ElementQuery
$structureId integer, false, null The structure ID that should be used to join in the structureelements table. craft\elements\db\ElementQuery
$subQuery craft\db\Query, null The subselect’s query object created by prepare() craft\elements\db\ElementQuery
$title string, string[], null The title that resulting elements must have. craft\elements\db\ElementQuery
$uid string, string[], null The element UID(s). craft\elements\db\ElementQuery
$union array This is used to construct the UNION clause(s) in a SQL statement. yii\db\Query
$uri string, string[], null The URI that the resulting element must have. craft\elements\db\ElementQuery
$where string, array Query condition. yii\db\QueryTrait
$with string, array, null The eager-loading declaration craft\elements\db\ElementQuery
$withStructure boolean, null Whether element structure data should automatically be left-joined into the query. craft\elements\db\ElementQuery
Protected Properties
Property Type Description Defined By
$defaultOrderBy array The default orderBy() value to use if orderBy() is empty but not null. craft\elements\db\ElementQuery
Public Methods
Method Description Defined By
__call() Calls the named method which is not a class method. craft\elements\db\ElementQuery
__clone() This method is called after the object is created by cloning an existing one. yii\base\Component
__construct() Constructor craft\elements\db\GlobalSetQuery
__get() Returns the value of a component property. craft\elements\db\ElementQuery
__isset() Checks if a property is set, i.e. defined and not null. craft\elements\db\ElementQuery
__set() Sets the value of a component property. craft\elements\db\ElementQuery
__toString() Returns the SQL representation of Query yii\db\Query
__unset() Sets an object property to null. yii\base\BaseObject
addGroupBy() Adds additional group-by columns to the existing ones. yii\db\Query
addOrderBy() Adds additional ORDER BY columns to the query. yii\db\QueryTrait
addParams() Adds additional parameters to be bound to the query. yii\db\Query
addSelect() Add more columns to the SELECT part of the query. yii\db\Query
all() Executes the query and returns all results as an array. craft\elements\db\ElementQuery
ancestorDist() Sets the ancestorDist() property. craft\elements\db\ElementQuery
ancestorOf() Sets the ancestorOf() property. craft\elements\db\ElementQuery
andFilterCompare() Adds a filtering condition for a specific column and allow the user to choose a filter operator. yii\db\Query
andFilterHaving() Adds an additional HAVING condition to the existing one but ignores empty operands. yii\db\Query
andFilterWhere() Adds an additional WHERE condition to the existing one but ignores empty operands. yii\db\QueryTrait
andHaving() Adds an additional HAVING condition to the existing one. yii\db\Query
andWhere() Adds an additional WHERE condition to the existing one. yii\db\QueryTrait
archived() Sets the archived() property. craft\elements\db\ElementQuery
asArray() Sets the asArray() property. craft\elements\db\ElementQuery
attachBehavior() Attaches a behavior to this component. yii\base\Component
attachBehaviors() Attaches a list of behaviors to the component. yii\base\Component
average() Returns the average of the specified column values. yii\db\Query
batch() Starts a batch query. yii\db\Query
behaviors() Returns a list of behaviors that this component should behave as. craft\elements\db\ElementQuery
cache() Enables query cache for this Query. yii\db\Query
canGetProperty() Returns a value indicating whether a property can be read. yii\base\BaseObject
canSetProperty() Returns a value indicating whether a property can be set. yii\base\BaseObject
className() Returns the fully qualified name of this class. yii\base\BaseObject
column() Executes the query and returns the first column of the result. craft\db\Query
count() Returns the number of records. craft\elements\db\ElementQuery
create() Creates a new Query object and copies its property values from an existing one. yii\db\Query
createCommand() Creates a DB command that can be used to execute this query. yii\db\Query
criteriaAttributes() Returns the query's criteria attributes. craft\elements\db\ElementQuery
dateCreated() Sets the dateCreated() property. craft\elements\db\ElementQuery
dateUpdated() Sets the dateUpdated() property. craft\elements\db\ElementQuery
descendantDist() Sets the descendantDist() property. craft\elements\db\ElementQuery
descendantOf() Sets the descendantOf() property. craft\elements\db\ElementQuery
detachBehavior() Detaches a behavior from the component. yii\base\Component
detachBehaviors() Detaches all behaviors from the component. yii\base\Component
distinct() Sets the value indicating whether to SELECT DISTINCT or not. yii\db\Query
each() Starts a batch query and retrieves data row by row. yii\db\Query
editable() Sets the editable() property. craft\elements\db\GlobalSetQuery
emulateExecution() Sets whether to emulate query execution, preventing any interaction with data storage. yii\db\QueryTrait
enabledForSite() Sets the enabledForSite() property. craft\elements\db\ElementQuery
ensureBehaviors() Makes sure that the behaviors declared in behaviors() are attached to this component. yii\base\Component
exists() Returns a value indicating whether the query result contains any row of data. craft\db\Query
extraFields() Returns the list of fields that can be expanded further and returned by toArray(). yii\base\ArrayableTrait
fields() Returns the list of fields that should be returned by default by toArray() when no specific fields are specified. yii\base\ArrayableTrait
filterHaving() Sets the HAVING part of the query but ignores empty operands. yii\db\Query
filterWhere() Sets the WHERE part of the query but ignores empty operands. yii\db\QueryTrait
find() Returns all elements that match the criteria. craft\elements\db\ElementQuery
first() Returns the first element that matches the criteria. craft\elements\db\ElementQuery
fixedOrder() Sets the fixedOrder() property. craft\elements\db\ElementQuery
from() Sets the FROM part of the query. yii\db\Query
getBehavior() Returns the named behavior object. yii\base\Component
getBehaviors() Returns all behaviors attached to this component. yii\base\Component
getCachedResult() Returns the resulting elements set by setCachedResult(), if the criteria params haven’t changed since then. craft\elements\db\ElementQuery
getCriteria() Returns an array of the current criteria attribute values. craft\elements\db\ElementQuery
getIterator() Required by the IteratorAggregate interface. craft\elements\db\ElementQuery
getRawSql() Shortcut for createCommand()->getRawSql(). craft\db\Query
getTablesUsedInFrom() Returns table names used in from() indexed by aliases. yii\db\Query
groupBy() Sets the GROUP BY part of the query. yii\db\Query
handle() Sets the handle() property. craft\elements\db\GlobalSetQuery
hasEventHandlers() Returns a value indicating whether there is any handler attached to the named event. yii\base\Component
hasMethod() Returns a value indicating whether a method is defined. yii\base\BaseObject
hasProperty() Returns a value indicating whether a property is defined. yii\base\BaseObject
having() Sets the HAVING part of the query. yii\db\Query
id() Sets the id() property. craft\elements\db\ElementQuery
ids() Executes the query and returns the IDs of the resulting elements. craft\elements\db\ElementQuery
inReverse() Sets the inReverse() property. craft\elements\db\ElementQuery
indexBy() Sets the indexBy() property. yii\db\QueryTrait
init() Initializes the object. craft\db\Query
innerJoin() Appends an INNER JOIN part to the query. yii\db\Query
isJoined() Returns whether a given table has been joined in this query. craft\db\Query
join() Appends a JOIN part to the query. yii\db\Query
last() Returns the last element that matches the criteria. craft\elements\db\ElementQuery
leftJoin() Appends a LEFT OUTER JOIN part to the query. yii\db\Query
level() Sets the level() property. craft\elements\db\ElementQuery
limit() Sets the LIMIT part of the query. yii\db\QueryTrait
locale() Sets the site() property. craft\elements\db\ElementQuery
localeEnabled() Sets the enabledForSite() property. craft\elements\db\ElementQuery
max() Returns the maximum of the specified column values. yii\db\Query
min() Returns the minimum of the specified column values. yii\db\Query
nextSiblingOf() Sets the nextSiblingOf() property. craft\elements\db\ElementQuery
noCache() Disables query cache for this Query. yii\db\Query
nth() Executes the query and returns a single row of result at a given offset. craft\elements\db\ElementQuery
off() Detaches an existing event handler from this component. yii\base\Component
offset() Sets the OFFSET part of the query. yii\db\QueryTrait
offsetExists() Required by the ArrayAccess interface. craft\elements\db\ElementQuery
offsetGet() Required by the ArrayAccess interface. craft\elements\db\ElementQuery
offsetSet() Required by the ArrayAccess interface. craft\elements\db\ElementQuery
offsetUnset() Required by the ArrayAccess interface. craft\elements\db\ElementQuery
on() Attaches an event handler to an event. yii\base\Component
one() Executes the query and returns a single row of result. craft\elements\db\ElementQuery
orFilterHaving() Adds an additional HAVING condition to the existing one but ignores empty operands. yii\db\Query
orFilterWhere() Adds an additional WHERE condition to the existing one but ignores empty operands. yii\db\QueryTrait
orHaving() Adds an additional HAVING condition to the existing one. yii\db\Query
orWhere() Adds an additional WHERE condition to the existing one. yii\db\QueryTrait
order() Sets the orderBy() property. craft\elements\db\ElementQuery
orderBy() Sets the ORDER BY part of the query. yii\db\QueryTrait
pairs() Executes the query and returns the first two columns in the results as key/value pairs. craft\db\Query
params() Sets the parameters to be bound to the query. yii\db\Query
populate() Converts the raw query results into the format as specified by this query. craft\elements\db\ElementQuery
positionedAfter() Sets the positionedAfter() property. craft\elements\db\ElementQuery
positionedBefore() Sets the positionedBefore() property. craft\elements\db\ElementQuery
prepare() Prepares for building SQL. craft\elements\db\ElementQuery
prevSiblingOf() Sets the prevSiblingOf() property. craft\elements\db\ElementQuery
ref() Sets the ref() property. craft\elements\db\ElementQuery
relatedTo() Sets the relatedTo() property. craft\elements\db\ElementQuery
rightJoin() Appends a RIGHT OUTER JOIN part to the query. yii\db\Query
scalar() Returns the query result as a scalar value. craft\db\Query
search() Sets the search() property. craft\elements\db\ElementQuery
select() Sets the SELECT part of the query. yii\db\Query
setCachedResult() Sets the resulting elements. craft\elements\db\ElementQuery
siblingOf() Sets the siblingOf() property. craft\elements\db\ElementQuery
site() Sets the siteId() property based on a given site(s)’s handle. craft\elements\db\ElementQuery
siteId() Sets the siteId() property. craft\elements\db\ElementQuery
slug() Sets the slug() property. craft\elements\db\ElementQuery
status() Sets the status() property. craft\elements\db\ElementQuery
structureId() Sets the structureId() property. craft\elements\db\ElementQuery
sum() Returns the sum of the specified column values. yii\db\Query
title() Sets the title() property. craft\elements\db\ElementQuery
toArray() Converts the model into an array. yii\base\ArrayableTrait
total() Returns the total elements that match the criteria. craft\elements\db\ElementQuery
trigger() Triggers an event. yii\base\Component
uid() Sets the uid() property. craft\elements\db\ElementQuery
union() Appends a SQL statement using UNION operator. yii\db\Query
uri() Sets the uri() property. craft\elements\db\ElementQuery
where() Sets the WHERE part of the query. yii\db\QueryTrait
with() Sets the with() property. craft\elements\db\ElementQuery
withStructure() Sets the withStructure() property. craft\elements\db\ElementQuery
Protected Methods
Method Description Defined By
afterPrepare() This method is called at the end of preparing an element query for the query builder. craft\elements\db\ElementQuery
beforePrepare() This method is called at the beginning of preparing an element query for the query builder. craft\elements\db\GlobalSetQuery
cleanUpTableNames() Clean up table names and aliases Both aliases and names are enclosed into {{ and }}. yii\db\Query
customFields() Returns the fields that should take part in an upcoming elements query. craft\elements\db\ElementQuery
extractFieldsFor() Extract nested fields from a fields collection for a given root field Nested fields are separated with dots (.). e.g: "item.id" The previous example would extract "id". yii\base\ArrayableTrait
extractRootFields() Extracts the root field names from nested fields. yii\base\ArrayableTrait
filterCondition() Removes empty operands from the given query condition. yii\db\QueryTrait
getUnaliasedColumnsFromSelect() yii\db\Query
getUniqueColumns() Returns unique column names excluding duplicates. yii\db\Query
isEmpty() Returns a value indicating whether the give value is "empty". yii\db\QueryTrait
joinElementTable() Joins in a table with an id column that has a foreign key pointing to craft_elements.id. craft\elements\db\ElementQuery
normalizeOrderBy() Normalizes format of ORDER BY data. yii\db\QueryTrait
queryScalar() Queries a scalar value by setting select() first. craft\db\Query
resolveFields() Determines which fields can be returned by toArray(). yii\base\ArrayableTrait
setCommandCache() Sets $command cache, if this query has enabled caching. yii\db\Query
statusCondition() Returns the condition that should be applied to the element query for a given status. craft\elements\db\ElementQuery
Events
Event Type Description Defined By
EVENT_AFTER_POPULATE_ELEMENT craft\events\PopulateElementEvent The event that is triggered after an element is populated. craft\elements\db\ElementQuery
EVENT_AFTER_PREPARE \craft\elements\db\Event An event that is triggered at the end of preparing an element query for the query builder. craft\elements\db\ElementQuery
EVENT_BEFORE_PREPARE \craft\elements\db\Event An event that is triggered at the beginning of preparing an element query for the query builder. craft\elements\db\ElementQuery
EVENT_DEFINE_BEHAVIORS craft\events\DefineBehaviorsEvent The event that is triggered when defining the class behaviors craft\db\Query
EVENT_INIT yii\base\Event The event that is triggered after the query's init cycle craft\db\Query

Property Details

$editable public property #

Whether to only return global sets that the user has permission to edit.

public boolean $editable false

$handle public property #

The handle(s) that the resulting global sets must have.

public string, string[], null $handle null

Method Details

__construct() public method #

Constructor

public void __construct ( $elementType, array $config = [] )
$elementType string The element type class associated with this query
$config array Configurations to be applied to the newly created query object

beforePrepare() protected method #

This method is called at the beginning of preparing an element query for the query builder.

The main Query object being prepared for the query builder is available via $query. The subselect’s Query object being prepared is available via $subQuery. The role of the subselect query is to apply conditions to the query and narrow the result set down to just the elements that should actually be returned. The role of the main query is to join in any tables that should be included in the results, and select all of the columns that should be included in the results.

protected boolean beforePrepare ( )
return boolean Whether the query should be prepared and returned to the query builder. If false, the query will be cancelled and no results will be returned.

editable() public method #

Sets the editable() property.

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

handle() public method #

Sets the handle() property.

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