mirror of
https://github.com/dg/dibi.git
synced 2025-08-04 05:07:36 +02:00
updated examples & Debugger
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
|
||||
<?php
|
||||
|
||||
require_once 'Nette/Debug.php';
|
||||
require_once 'Nette/Debugger.php';
|
||||
require_once '../dibi/dibi.php';
|
||||
|
||||
|
||||
@@ -29,38 +29,38 @@ product_id | title
|
||||
// fetch a single row
|
||||
echo "<h2>fetch()</h2>\n";
|
||||
$row = dibi::fetch('SELECT title FROM products');
|
||||
Debug::dump($row); // Chair
|
||||
Debugger::dump($row); // Chair
|
||||
|
||||
|
||||
// fetch a single value
|
||||
echo "<h2>fetchSingle()</h2>\n";
|
||||
$value = dibi::fetchSingle('SELECT title FROM products');
|
||||
Debug::dump($value); // Chair
|
||||
Debugger::dump($value); // Chair
|
||||
|
||||
|
||||
// fetch complete result set
|
||||
echo "<h2>fetchAll()</h2>\n";
|
||||
$all = dibi::fetchAll('SELECT * FROM products');
|
||||
Debug::dump($all);
|
||||
Debugger::dump($all);
|
||||
|
||||
|
||||
// fetch complete result set like association array
|
||||
echo "<h2>fetchAssoc('title')</h2>\n";
|
||||
$res = dibi::query('SELECT * FROM products');
|
||||
$assoc = $res->fetchAssoc('title'); // key
|
||||
Debug::dump($assoc);
|
||||
Debugger::dump($assoc);
|
||||
|
||||
|
||||
// fetch complete result set like pairs key => value
|
||||
echo "<h2>fetchPairs('product_id', 'title')</h2>\n";
|
||||
$pairs = $res->fetchPairs('product_id', 'title');
|
||||
Debug::dump($pairs);
|
||||
Debugger::dump($pairs);
|
||||
|
||||
|
||||
// fetch row by row
|
||||
echo "<h2>using foreach</h2>\n";
|
||||
foreach ($res as $n => $row) {
|
||||
Debug::dump($row);
|
||||
Debugger::dump($row);
|
||||
}
|
||||
|
||||
|
||||
@@ -74,12 +74,12 @@ $res = dibi::query('
|
||||
|
||||
echo "<h2>fetchAssoc('customers.name|products.title')</h2>\n";
|
||||
$assoc = $res->fetchAssoc('customers.name|products.title'); // key
|
||||
Debug::dump($assoc);
|
||||
Debugger::dump($assoc);
|
||||
|
||||
echo "<h2>fetchAssoc('customers.name[]products.title')</h2>\n";
|
||||
$assoc = $res->fetchAssoc('customers.name[]products.title'); // key
|
||||
Debug::dump($assoc);
|
||||
Debugger::dump($assoc);
|
||||
|
||||
echo "<h2>fetchAssoc('customers.name->products.title')</h2>\n";
|
||||
$assoc = $res->fetchAssoc('customers.name->products.title'); // key
|
||||
Debug::dump($assoc);
|
||||
Debugger::dump($assoc);
|
||||
|
Reference in New Issue
Block a user