You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
| [afterPopulate](#afterpopulate) | Performs any post-population processing on elements.
12
11
| [andRelatedTo](#andrelatedto) | Narrows the query results to only elements that are related to certain other elements.
12
+
| [andWith](#andwith) | Causes the query to return matching elements eager-loaded with related elements, in addition to the elements that were already specified by [with](#with).
13
13
| [asArray](#asarray) | Causes the query to return matching elements as arrays of data, rather than ElementClass objects.
14
14
| [cache](#cache) | Enables query cache for this Query.
15
15
| [clearCachedResult](#clearcachedresult) | Clears the [cached result](https://craftcms.com/docs/4.x/element-queries.html#cache).
@@ -32,26 +32,16 @@
32
32
| [trashed](#trashed) | Narrows the query results to only elements that have been soft-deleted.
33
33
| [uid](#uid) | Narrows the query results based on the elements’ UIDs.
34
34
| [with](#with) | Causes the query to return matching elements eager-loaded with related elements.
35
+
| [withCustomFields](#withcustomfields) | Sets whether custom fields should be factored into the query.
35
36
36
37
37
38
<!-- textlint-enable -->
38
39
39
40
40
-
#### `afterPopulate`
41
-
42
-
Performs any post-population processing on elements.
43
-
44
-
45
-
46
-
47
-
48
-
49
-
50
-
51
-
52
-
53
41
#### `andRelatedTo`
54
42
43
+
<aclass="ref-defined-by"href="https://docs.craftcms.com/api/v4/craft-elements-db-elementquery.html#method-andrelatedto"target="_blank"rel="noopener noreferer">Defined by <code>craft\elements\db\ElementQuery</code></a>
44
+
55
45
Narrows the query results to only elements that are related to certain other elements.
<aclass="ref-defined-by"href="https://docs.craftcms.com/api/v4/craft-elements-db-elementquery.html#method-andwith"target="_blank"rel="noopener noreferer">Defined by <code>craft\elements\db\ElementQuery</code></a>
75
+
76
+
Causes the query to return matching elements eager-loaded with related elements, in addition to the elements that were already specified by [with](#with).
77
+
78
+
79
+
80
+
.
81
+
82
+
83
+
84
+
85
+
86
+
82
87
#### `asArray`
83
88
89
+
<aclass="ref-defined-by"href="https://docs.craftcms.com/api/v4/craft-elements-db-elementquery.html#method-asarray"target="_blank"rel="noopener noreferer">Defined by <code>craft\elements\db\ElementQuery</code></a>
90
+
84
91
Causes the query to return matching elements as arrays of data, rather than ElementClass objects.
<aclass="ref-defined-by"href="https://docs.craftcms.com/api/v4/craft-elements-db-elementquery.html#method-cache"target="_blank"rel="noopener noreferer">Defined by <code>craft\elements\db\ElementQuery</code></a>
117
+
109
118
Enables query cache for this Query.
110
119
111
120
@@ -119,6 +128,8 @@ Enables query cache for this Query.
119
128
120
129
#### `clearCachedResult`
121
130
131
+
<aclass="ref-defined-by"href="https://docs.craftcms.com/api/v4/craft-elements-db-elementquery.html#method-clearcachedresult"target="_blank"rel="noopener noreferer">Defined by <code>craft\elements\db\ElementQuery</code></a>
132
+
122
133
Clears the [cached result](https://craftcms.com/docs/4.x/element-queries.html#cache).
123
134
124
135
@@ -128,6 +139,8 @@ Clears the [cached result](https://craftcms.com/docs/4.x/element-queries.html#ca
128
139
129
140
#### `dateCreated`
130
141
142
+
<aclass="ref-defined-by"href="https://docs.craftcms.com/api/v4/craft-elements-db-elementquery.html#method-datecreated"target="_blank"rel="noopener noreferer">Defined by <code>craft\elements\db\ElementQuery</code></a>
143
+
131
144
Narrows the query results based on the elements’ creation dates.
<aclass="ref-defined-by"href="https://docs.craftcms.com/api/v4/craft-elements-db-elementquery.html#method-dateupdated"target="_blank"rel="noopener noreferer">Defined by <code>craft\elements\db\ElementQuery</code></a>
185
+
171
186
Narrows the query results based on the elements’ last-updated dates.
<aclass="ref-defined-by"href="https://docs.craftcms.com/api/v4/craft-elements-db-elementquery.html#method-fixedorder"target="_blank"rel="noopener noreferer">Defined by <code>craft\elements\db\ElementQuery</code></a>
225
+
209
226
Causes the query results to be returned in the order specified by [id](#id).
<aclass="ref-defined-by"href="https://docs.craftcms.com/api/v4/craft-elements-db-elementquery.html#method-id"target="_blank"rel="noopener noreferer">Defined by <code>craft\elements\db\ElementQuery</code></a>
258
+
240
259
Narrows the query results based on the elements’ IDs.
241
260
242
261
@@ -277,6 +296,8 @@ This can be combined with [fixedOrder](#fixedorder) if you want the results to b
277
296
278
297
#### `ignorePlaceholders`
279
298
299
+
<aclass="ref-defined-by"href="https://docs.craftcms.com/api/v4/craft-elements-db-elementquery.html#method-ignoreplaceholders"target="_blank"rel="noopener noreferer">Defined by <code>craft\elements\db\ElementQuery</code></a>
300
+
280
301
Causes the query to return matching elements as they are stored in the database, ignoring matching placeholder
281
302
elements that were set by [craft\services\Elements::setPlaceholderElement()](https://docs.craftcms.com/api/v4/craft-services-elements.html#method-setplaceholderelement).
282
303
@@ -291,6 +312,8 @@ elements that were set by [craft\services\Elements::setPlaceholderElement()](htt
291
312
292
313
#### `inReverse`
293
314
315
+
<aclass="ref-defined-by"href="https://docs.craftcms.com/api/v4/craft-elements-db-elementquery.html#method-inreverse"target="_blank"rel="noopener noreferer">Defined by <code>craft\elements\db\ElementQuery</code></a>
316
+
294
317
Causes the query results to be returned in reverse order.
<aclass="ref-defined-by"href="https://docs.craftcms.com/api/v4/craft-elements-db-elementquery.html#method-language"target="_blank"rel="noopener noreferer">Defined by <code>craft\elements\db\ElementQuery</code></a>
343
+
319
344
Determines which site(s) the elements should be queried in, based on their language.
<aclass="ref-defined-by"href="https://www.yiiframework.com/doc/api/2.0/yii-db-querytrait#limit()-detail"target="_blank"rel="noopener noreferer">Defined by <code>yii\db\QueryTrait</code></a>
383
+
357
384
Determines the number of elements that should be returned.
<aclass="ref-defined-by"href="https://www.yiiframework.com/doc/api/2.0/yii-db-querytrait#offset()-detail"target="_blank"rel="noopener noreferer">Defined by <code>yii\db\QueryTrait</code></a>
408
+
380
409
Determines how many elements should be skipped in the results.
<aclass="ref-defined-by"href="https://docs.craftcms.com/api/v4/craft-elements-db-elementquery.html#method-orderby"target="_blank"rel="noopener noreferer">Defined by <code>craft\elements\db\ElementQuery</code></a>
433
+
403
434
Determines the order that the elements should be returned in. (If empty, defaults to `dateCreated DESC,
<aclass="ref-defined-by"href="https://docs.craftcms.com/api/v4/craft-elements-db-elementquery.html#method-prefersites"target="_blank"rel="noopener noreferer">Defined by <code>craft\elements\db\ElementQuery</code></a>
459
+
427
460
If [unique()](https://docs.craftcms.com/api/v4/craft-elements-db-elementquery.html#method-unique) is set, this determines which site should be selected when querying multi-site elements.
<aclass="ref-defined-by"href="https://docs.craftcms.com/api/v4/craft-elements-db-elementquery.html#method-preparesubquery"target="_blank"rel="noopener noreferer">Defined by <code>craft\elements\db\ElementQuery</code></a>
496
+
462
497
Prepares the element query and returns its subquery (which determines what elements will be returned).
463
498
464
499
@@ -468,6 +503,8 @@ Prepares the element query and returns its subquery (which determines what eleme
468
503
469
504
#### `relatedTo`
470
505
506
+
<aclass="ref-defined-by"href="https://docs.craftcms.com/api/v4/craft-elements-db-elementquery.html#method-relatedto"target="_blank"rel="noopener noreferer">Defined by <code>craft\elements\db\ElementQuery</code></a>
507
+
471
508
Narrows the query results to only elements that are related to certain other elements.
<aclass="ref-defined-by"href="https://docs.craftcms.com/api/v4/craft-elements-db-elementquery.html#method-search"target="_blank"rel="noopener noreferer">Defined by <code>craft\elements\db\ElementQuery</code></a>
536
+
498
537
Narrows the query results to only elements that match a search query.
<aclass="ref-defined-by"href="https://docs.craftcms.com/api/v4/craft-elements-db-elementquery.html#method-sitesettingsid"target="_blank"rel="noopener noreferer">Defined by <code>craft\elements\db\ElementQuery</code></a>
571
+
531
572
Narrows the query results based on the elements’ IDs in the `elements_sites` table.
<aclass="ref-defined-by"href="https://docs.craftcms.com/api/v4/craft-elements-db-elementquery.html#method-trashed"target="_blank"rel="noopener noreferer">Defined by <code>craft\elements\db\ElementQuery</code></a>
639
+
596
640
Narrows the query results to only elements that have been soft-deleted.
<aclass="ref-defined-by"href="https://docs.craftcms.com/api/v4/craft-elements-db-elementquery.html#method-uid"target="_blank"rel="noopener noreferer">Defined by <code>craft\elements\db\ElementQuery</code></a>
666
+
621
667
Narrows the query results based on the elements’ UIDs.
<aclass="ref-defined-by"href="https://docs.craftcms.com/api/v4/craft-elements-db-elementquery.html#method-with"target="_blank"rel="noopener noreferer">Defined by <code>craft\elements\db\ElementQuery</code></a>
693
+
646
694
Causes the query to return matching elements eager-loaded with related elements.
<aclass="ref-defined-by"href="https://docs.craftcms.com/api/v4/craft-elements-db-elementquery.html#method-withcustomfields"target="_blank"rel="noopener noreferer">Defined by <code>craft\elements\db\ElementQuery</code></a>
722
+
723
+
Sets whether custom fields should be factored into the query.
0 commit comments