pq\Transaction docs
[mdref/mdref-pq] / pq / Result / fetchCol.md
1 # bool pq\Result::fetchCol(mixed &$ref[, mixed $col = 0])
2
3 Iteratively fetch a single column.
4
5 ## Params:
6
7 * mixed $ref
8 The variable where the column value will be stored in.
9 * Optional mixed $col = 0
10 The column name or index.
11
12 ## Returns:
13
14 * bool, success.
15 * NULL, when iteration ends.
16
17 ## Throws:
18
19 * pq\Exception\InvalidArgumentException
20 * pq\Exception\BadMethodCallException
21 * pq\Exception\RuntimeException
22
23 ## Example:
24
25 <?php
26
27 try {
28 $connection = new pq\Connection;
29
30 $result = $connection->exec("SELECT email FROM accounts WHERE email LIKE '_@%'");
31
32 while ($result->fetchCol($email)) {
33 echo "Mail: {$email}\n";
34 }
35 } catch (\pq\Exception $e) {
36 echo $e->getMessage(), "\n";
37 }
38
39 ?>