pq\LOB docs
[mdref/mdref-pq] / pq / Result / fetchAll.md
1 # array pq\Result::fetchAll([int $fetch_type = pq\Result::$fetchType])
2
3 Fetch all rows at once.
4
5 ## Params:
6
7 * Optional int $fetch_type = pq\Result::$fetchType
8 The type the return value should have, see pq\Result::FETCH_* constants.
9
10 ## Returns:
11
12 * array, all fetched rows.
13
14 ## Throws:
15
16 * pq\Exception\InvalidArgumentException
17 * pq\Exception\BadMethodCallException
18
19 ## Example:
20
21 <?php
22
23 try {
24 $connection = new pq\Connection;
25
26 $result = $connection->exec("SELECT id, name, email FROM accounts WHERE email LIKE '_@%'");
27
28 foreach ($result->fetchAll(pq\Result::FETCH_OBJECT) as $row) {
29 echo "ID: {$row->id}\n";
30 echo "Name: {$row->name}\n";
31 echo "Mail: {$row->email}\n\n";
32 }
33 } catch (\pq\Exception $e) {
34 echo $e->getMessage(), "\n";
35 }
36
37 ?>
38