diff --git a/reference/pdo/pdostatement/fetchall.xml b/reference/pdo/pdostatement/fetchall.xml
index c78ba185e1..e4ea7a7fb2 100644
--- a/reference/pdo/pdostatement/fetchall.xml
+++ b/reference/pdo/pdostatement/fetchall.xml
@@ -12,7 +12,7 @@
arrayPDOStatement::fetchAll
intfetch_stylePDO::FETCH_BOTH
- intfetch_argument0
+ mixedfetch_argument
arrayctor_argsarray()
@@ -31,19 +31,19 @@
To return an array consisting of all values of a single column from
- the result set, specify PDO::FETCH_COLUMN. You
+ the result set, specify PDO::FETCH_COLUMN. You
can specify which column you want with the
column-index parameter.
To fetch only the unique values of a single column from the result set,
- bitwise-OR PDO::FETCH_COLUMN with
- PDO::FETCH_UNIQUE.
+ bitwise-OR PDO::FETCH_COLUMN with
+ PDO::FETCH_UNIQUE.
To return an associative array grouped by the values of a specified
- column, bitwise-OR PDO::FETCH_COLUMN with
- PDO::FETCH_GROUP.
+ column, bitwise-OR PDO::FETCH_COLUMN with
+ PDO::FETCH_GROUP.
@@ -62,8 +62,14 @@
- PDO::FETCH_CLASS: Sets a custom class name for which
- the fetch results will be stored in.
+ PDO::FETCH_CLASS: Returns instances of the specified
+ class, mapping the columns of each row to named properties in the class.
+
+
+
+
+ PDO::FETCH_FUNC: Returns the results of calling the
+ specified function, using each row's columns as parameters in the call.
@@ -226,6 +232,90 @@ array(3) {
}
}
+]]>
+
+
+ Instantiating a class for each result
+
+ The following example demonstrates the behaviour of the
+ PDO::FETCH_CLASS fetch style.
+
+
+prepare("SELECT name, colour FROM fruit");
+$sth->execute();
+
+$result = $sth->fetchAll(PDO::FETCH_CLASS, "fruit");
+var_dump($result);
+?>
+]]>
+
+ &example.outputs;
+
+
+ object(fruit)#1 (2) {
+ ["name"]=>
+ string(5) "apple"
+ ["colour"]=>
+ string(5) "green"
+ }
+ [1]=>
+ object(fruit)#2 (2) {
+ ["name"]=>
+ string(4) "pear"
+ ["colour"]=>
+ string(6) "yellow"
+ }
+ [2]=>
+ object(fruit)#3 (2) {
+ ["name"]=>
+ string(10) "watermelon"
+ ["colour"]=>
+ string(4) "pink"
+ }
+}
+]]>
+
+
+ Calling a function for each result
+
+ The following example demonstrates the behaviour of the
+ PDO::FETCH_FUNC fetch style.
+
+
+prepare("SELECT name, colour FROM fruit");
+$sth->execute();
+
+$result = $sth->fetchAll(PDO::FETCH_FUNC, "fruit");
+var_dump($result);
+?>
+]]>
+
+ &example.outputs;
+
+
+ string(12) "apple: green"
+ [1]=>
+ string(12) "pear: yellow"
+ [2]=>
+ string(16) "watermelon: pink"
+}
]]>