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
| [addOrderBy](#addorderby) | Adds additional ORDER BY columns to the query.
12
11
| [afterPopulate](#afterpopulate) | Performs any post-population processing on elements.
13
12
| [andRelatedTo](#andrelatedto) | Narrows the query results to only assets that are related to certain other elements.
14
13
| [anyStatus](#anystatus) | Removes element filters based on their statuses.
@@ -18,7 +17,6 @@
18
17
| [dateCreated](#datecreated) | Narrows the query results based on the assets’ creation dates.
19
18
| [dateModified](#datemodified) | Narrows the query results based on the assets’ files’ last-modified dates.
20
19
| [dateUpdated](#dateupdated) | Narrows the query results based on the assets’ last-updated dates.
21
-
| [fields](#fields) | Returns the list of fields that should be returned by default by [toArray()](https://www.yiiframework.com/doc/api/2.0/yii-base-arrayabletrait#toArray()-detail) when no specific fields are specified.
22
20
| [filename](#filename) | Narrows the query results based on the assets’ filenames.
23
21
| [fixedOrder](#fixedorder) | Causes the query results to be returned in the order specified by [id](#id).
24
22
| [folderId](#folderid) | Narrows the query results based on the folders the assets belong to, per the folders’ IDs.
@@ -54,19 +52,6 @@
54
52
<!-- textlint-enable -->
55
53
56
54
57
-
#### `addOrderBy`
58
-
59
-
Adds additional ORDER BY columns to the query.
60
-
61
-
62
-
63
-
64
-
65
-
66
-
67
-
68
-
69
-
70
55
#### `afterPopulate`
71
56
72
57
Performs any post-population processing on elements.
Returns the list of fields that should be returned by default by [toArray()](https://www.yiiframework.com/doc/api/2.0/yii-base-arrayabletrait#toArray()-detail) when no specific fields are specified.
298
-
299
-
A field is a named element in the returned array by [toArray()](https://www.yiiframework.com/doc/api/2.0/yii-base-arrayabletrait#toArray()-detail).
300
-
This method should return an array of field names or field definitions.
301
-
If the former, the field name will be treated as an object property name whose value will be used
302
-
as the field value. If the latter, the array key should be the field name while the array value should be
303
-
the corresponding field definition which can be either an object property name or a PHP callable
304
-
returning the corresponding field value. The signature of the callable should be:
305
-
306
-
```php
307
-
function ($model, $field) {
308
-
// return field value
309
-
}
310
-
```
311
-
312
-
For example, the following code declares four fields:
313
-
314
-
-`email`: the field name is the same as the property name `email`;
315
-
-`firstName` and `lastName`: the field names are `firstName` and `lastName`, and their
316
-
values are obtained from the `first_name` and `last_name` properties;
317
-
-`fullName`: the field name is `fullName`. Its value is obtained by concatenating `first_name`
| [addOrderBy](#addorderby) | Adds additional ORDER BY columns to the query.
12
11
| [afterPopulate](#afterpopulate) | Performs any post-population processing on elements.
13
12
| [ancestorDist](#ancestordist) | Narrows the query results to only categories that are up to a certain distance away from the category specified by [ancestorOf](#ancestorof).
14
13
| [ancestorOf](#ancestorof) | Narrows the query results to only categories that are ancestors of another category in its structure.
@@ -21,7 +20,6 @@
21
20
| [dateUpdated](#dateupdated) | Narrows the query results based on the categories’ last-updated dates.
22
21
| [descendantDist](#descendantdist) | Narrows the query results to only categories that are up to a certain distance away from the category specified by [descendantOf](#descendantof).
23
22
| [descendantOf](#descendantof) | Narrows the query results to only categories that are descendants of another category in its structure.
24
-
| [fields](#fields) | Returns the list of fields that should be returned by default by [toArray()](https://www.yiiframework.com/doc/api/2.0/yii-base-arrayabletrait#toArray()-detail) when no specific fields are specified.
25
23
| [fixedOrder](#fixedorder) | Causes the query results to be returned in the order specified by [id](#id).
26
24
| [group](#group) | Narrows the query results based on the category groups the categories belong to.
27
25
| [groupId](#groupid) | Narrows the query results based on the category groups the categories belong to, per the groups’ IDs.
@@ -58,19 +56,6 @@
58
56
<!-- textlint-enable -->
59
57
60
58
61
-
#### `addOrderBy`
62
-
63
-
Adds additional ORDER BY columns to the query.
64
-
65
-
66
-
67
-
68
-
69
-
70
-
71
-
72
-
73
-
74
59
#### `afterPopulate`
75
60
76
61
Performs any post-population processing on elements.
@@ -391,45 +376,6 @@ This can be combined with [descendantDist](#descendantdist) if you want to limit
391
376
:::
392
377
393
378
394
-
#### `fields`
395
-
396
-
Returns the list of fields that should be returned by default by [toArray()](https://www.yiiframework.com/doc/api/2.0/yii-base-arrayabletrait#toArray()-detail) when no specific fields are specified.
397
-
398
-
A field is a named element in the returned array by [toArray()](https://www.yiiframework.com/doc/api/2.0/yii-base-arrayabletrait#toArray()-detail).
399
-
This method should return an array of field names or field definitions.
400
-
If the former, the field name will be treated as an object property name whose value will be used
401
-
as the field value. If the latter, the array key should be the field name while the array value should be
402
-
the corresponding field definition which can be either an object property name or a PHP callable
403
-
returning the corresponding field value. The signature of the callable should be:
404
-
405
-
```php
406
-
function ($model, $field) {
407
-
// return field value
408
-
}
409
-
```
410
-
411
-
For example, the following code declares four fields:
412
-
413
-
-`email`: the field name is the same as the property name `email`;
414
-
-`firstName` and `lastName`: the field names are `firstName` and `lastName`, and their
415
-
values are obtained from the `first_name` and `last_name` properties;
416
-
-`fullName`: the field name is `fullName`. Its value is obtained by concatenating `first_name`
Copy file name to clipboardExpand all lines: docs/.artifacts/cms/3.x/config-db.md
+58
Original file line number
Diff line number
Diff line change
@@ -19,6 +19,18 @@ Defined by
19
19
20
20
An array of key => value pairs of PDO attributes to pass into the PDO constructor.
21
21
22
+
For example, when using the [MySQL PDO driver](https://php.net/manual/en/ref.pdo-mysql.php), if you wanted to enable a SSL database connection
23
+
(assuming [SSL is enabled in MySQL](https://dev.mysql.com/doc/mysql-secure-deployment-guide/5.7/en/secure-deployment-secure-connections.html) and `'user'` can connect via SSL,
You can change the character set and collation across all existing database tables using this terminal command:
55
+
56
+
```bash
57
+
> php craft db/convert-charset
58
+
```
59
+
:::
60
+
41
61
42
62
43
63
### `collation`
@@ -60,6 +80,21 @@ Since
60
80
61
81
The collation to use when creating tables.
62
82
83
+
This is only used by MySQL. If null, the [charset’s](https://docs.craftcms.com/api/v3/craft-config-dbconfig.html#property-charset) default collation will be used.
84
+
85
+
| Charset | Default collation |
86
+
| --------- | -------------------- |
87
+
|`utf8`|`utf8_general_ci`|
88
+
|`utf8mb4`|`utf8mb4_0900_ai_ci`|
89
+
90
+
::: tip
91
+
You can change the character set and collation across all existing database tables using this terminal command:
92
+
93
+
```bash
94
+
> php craft db/convert-charset
95
+
```
96
+
:::
97
+
63
98
64
99
65
100
### `database`
@@ -117,6 +152,12 @@ Defined by
117
152
118
153
The Data Source Name (“DSN”) that tells Craft how to connect to the database.
119
154
155
+
DSNs should begin with a driver prefix (`mysql:` or `pgsql:`), followed by driver-specific parameters.
156
+
For example, `mysql:host=127.0.0.1;port=3306;dbname=acme_corp`.
157
+
158
+
- MySQL parameters: <https://php.net/manual/en/ref.pdo-mysql.connection.php>
The schema that Postgres is configured to use by default (PostgreSQL only).
176
217
218
+
::: tip
219
+
To force Craft to use the specified schema regardless of PostgreSQL’s `search_path` setting, you must enable
220
+
the [setSchemaOnConnect](https://docs.craftcms.com/api/v3/craft-config-dbconfig.html#property-setschemaonconnect) setting.
221
+
:::
222
+
177
223
178
224
179
225
### `server`
@@ -215,6 +261,11 @@ Since
215
261
216
262
Whether the [schema](https://docs.craftcms.com/api/v3/craft-config-dbconfig.html#property-schema) should be explicitly used for database queries (PostgreSQL only).
217
263
264
+
::: warning
265
+
This will cause an extra `SET search_path` SQL query to be executed per database connection. Ideally,
266
+
PostgreSQL’s `search_path` setting should be configured to prioritize the desired schema.
267
+
:::
268
+
218
269
219
270
220
271
### `tablePrefix`
@@ -274,6 +325,8 @@ Defined by
274
325
275
326
The database connection URL, if one was provided by your hosting environment.
276
327
328
+
If this is set, the values for [driver](https://docs.craftcms.com/api/v3/craft-config-dbconfig.html#property-driver), [user](https://docs.craftcms.com/api/v3/craft-config-dbconfig.html#property-user), [database](https://docs.craftcms.com/api/v3/craft-config-dbconfig.html#property-database), [server](https://docs.craftcms.com/api/v3/craft-config-dbconfig.html#property-server), [port](https://docs.craftcms.com/api/v3/craft-config-dbconfig.html#property-port), and [database](https://docs.craftcms.com/api/v3/craft-config-dbconfig.html#property-database) will be extracted from it.
329
+
277
330
278
331
279
332
### `useUnbufferedConnections`
@@ -296,6 +349,11 @@ Since
296
349
297
350
Whether batched queries should be executed on a separate, unbuffered database connection.
298
351
352
+
This setting only applies to MySQL. It can be enabled when working with high volume content, to prevent
353
+
PHP from running out of memory when querying too much data at once. (See
354
+
<https://www.yiiframework.com/doc/guide/2.0/en/db-query-builder#batch-query-mysql> for an explanation
0 commit comments