missing bits
[mdref/mdref-pq] / pq / Result / bind.md
1 # bool pq\Result::bind(mixed $col, mixed &$var)
2
3 Bind a variable to a result column.
4 See pq\Result::fetchBound().
5
6 ## Params:
7
8 * mixed $col
9 The column name or index to bind to.
10 * mixed $var
11 The variable reference.
12
13 ## Returns:
14
15 * bool, success.
16
17 ## Throws:
18
19 * pq\Exception\InvalidArgumentException
20 * pq\Exception\BadMethodCallException
21
22 ## Example:
23
24 <?php
25
26 try {
27 $connection = new pq\Connection;
28
29 $result = $connection->exec("SELECT id, name, email FROM accounts WHERE email LIKE '_@%'");
30
31 $result->bind("id", $id);
32 $result->bind("name", $name);
33 $result->bind("email", $email);
34
35 while ($result->fetchBound()) {
36 echo "ID: {$id}\n";
37 echo "Name: {$name}\n";
38 echo "Mail: {$email}\n\n";
39 }
40 } catch (\pq\Exception $e) {
41 echo $e->getMessage(), "\n";
42 }
43
44 ?>
45