Skip to content

Commit 44bcc82

Browse files
authored
Update use cases for the mode parameter in PDOStatement::fetchAll() (#3549)
1 parent 21840cc commit 44bcc82

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

reference/pdo/pdostatement/fetchall.xml

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,22 @@
5454
<parameter>column</parameter> parameter.
5555
</para>
5656
<para>
57-
To fetch only the unique values of a single column from the result set,
58-
bitwise-OR <constant>PDO::FETCH_COLUMN</constant> with
59-
<constant>PDO::FETCH_UNIQUE</constant>.
57+
To index the resulting array by a certain column's value (instead of
58+
consecutive numbers), put this column's name first in the column
59+
list in SQL, and use <constant>PDO::FETCH_UNIQUE</constant>.
60+
This column must contain only unique values or some data will be lost.
6061
</para>
6162
<para>
62-
To return an associative array grouped by the values of a specified
63-
column, bitwise-OR <constant>PDO::FETCH_COLUMN</constant> with
64-
<constant>PDO::FETCH_GROUP</constant>.
63+
To group results in the form of a 3-dimensional array indexed by values
64+
of a specified column, put this column's name first in
65+
the column list in SQL and use <constant>PDO::FETCH_GROUP</constant>.
66+
</para>
67+
<para>
68+
To group results in the form of a 2-dimensional array
69+
use bitwise-OR <constant>PDO::FETCH_GROUP</constant> with
70+
<constant>PDO::FETCH_COLUMN</constant>.
71+
The results will be grouped by the first column, with the array element's value
72+
being a list array of the corresponding entries from the second column.
6573
</para>
6674
</listitem>
6775
</varlistentry>

0 commit comments

Comments
 (0)