diff --git a/examples/fetching-examples.php b/examples/fetching-examples.php index 9de2ca3..d02b647 100644 --- a/examples/fetching-examples.php +++ b/examples/fetching-examples.php @@ -54,12 +54,14 @@ dump($assoc); // fetch complete result set like pairs key => value echo "

fetchPairs('product_id', 'title')

\n"; +$res = dibi::query('SELECT * FROM products'); $pairs = $res->fetchPairs('product_id', 'title'); dump($pairs); // fetch row by row echo "

using foreach

\n"; +$res = dibi::query('SELECT * FROM products'); foreach ($res as $n => $row) { dump($row); } @@ -73,14 +75,16 @@ $res = dibi::query(' INNER JOIN customers USING (customer_id) '); -echo "

fetchAssoc('customers.name|products.title')

\n"; -$assoc = $res->fetchAssoc('customers.name|products.title'); // key +echo "

fetchAssoc('name|title')

\n"; +$assoc = $res->fetchAssoc('name|title'); // key dump($assoc); -echo "

fetchAssoc('customers.name[]products.title')

\n"; -$assoc = $res->fetchAssoc('customers.name[]products.title'); // key +echo "

fetchAssoc('name[]title')

\n"; +$res = dibi::query('SELECT * FROM products INNER JOIN orders USING (product_id) INNER JOIN customers USING (customer_id)'); +$assoc = $res->fetchAssoc('name[]title'); // key dump($assoc); -echo "

fetchAssoc('customers.name->products.title')

\n"; -$assoc = $res->fetchAssoc('customers.name->products.title'); // key +echo "

fetchAssoc('name->title')

\n"; +$res = dibi::query('SELECT * FROM products INNER JOIN orders USING (product_id) INNER JOIN customers USING (customer_id)'); +$assoc = $res->fetchAssoc('name->title'); // key dump($assoc);