1
0
mirror of https://github.com/dg/dibi.git synced 2025-01-17 14:18:25 +01:00

updated examples & Debugger

This commit is contained in:
David Grudl 2011-07-01 08:06:36 +02:00
parent ac1f45b397
commit 9c59fee929
18 changed files with 249 additions and 99 deletions

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@
<?php
require_once 'Nette/Debug.php';
require_once 'Nette/Debugger.php';
require_once '../dibi/dibi.php';

View File

@ -16,12 +16,6 @@ h2 {
font-size: 150%;
}
pre.dump {
border: 1px solid silver;
padding: 1em;
margin: 1em 0;
}
a {
color: #000080;
}
@ -45,3 +39,26 @@ table.dump th {
color: #525b37;
background: #e3e9ba;
}
/* dump() */
pre.nette-dump, pre.dump {
color: #444; background: white;
border: 1px solid silver;
padding: 1em;
margin: 1em 0;
}
pre.nette-dump .php-array, pre.nette-dump .php-object {
color: #C22;
}
pre.nette-dump .php-string {
color: #080;
}
pre.nette-dump .php-int, pre.nette-dump .php-float {
color: #37D;
}
pre.nette-dump .php-null, pre.nette-dump .php-bool {
color: black;
}
pre.nette-dump .php-visibility {
font-size: 85%; color: #999;
}

View File

@ -4,7 +4,7 @@
<?php
require_once 'Nette/Debug.php';
require_once 'Nette/Debugger.php';
require_once '../dibi/dibi.php';

View File

@ -4,7 +4,7 @@
<?php
require_once 'Nette/Debug.php';
require_once 'Nette/Debugger.php';
require_once '../dibi/dibi.php';

View File

@ -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);

View File

@ -4,7 +4,7 @@
<?php
require_once 'Nette/Debug.php';
require_once 'Nette/Debugger.php';
require_once '../dibi/dibi.php';

View File

@ -4,7 +4,7 @@
<?php
require_once 'Nette/Debug.php';
require_once 'Nette/Debugger.php';
require_once '../dibi/dibi.php';

View File

@ -4,7 +4,7 @@
<?php
require_once 'Nette/Debug.php';
require_once 'Nette/Debugger.php';
require_once '../dibi/dibi.php';
date_default_timezone_set('Europe/Prague');

View File

@ -4,7 +4,7 @@
<?php
require_once 'Nette/Debug.php';
require_once 'Nette/Debugger.php';
require_once '../dibi/dibi.php';
date_default_timezone_set('Europe/Prague');
@ -22,7 +22,7 @@ $res = dibi::query('SELECT * FROM [customers]');
$res->setType('customer_id', Dibi::INTEGER)
->setType('added', Dibi::DATETIME, 'H:i j.n.Y');
Debug::dump( $res->fetch() );
Debugger::dump( $res->fetch() );
// outputs:
// object(DibiRow)#3 (3) {
// customer_id => int(1)
@ -37,7 +37,7 @@ $res = dibi::query('SELECT * FROM [customers]');
$res->detectTypes();
Debug::dump( $res->fetch() );
Debugger::dump( $res->fetch() );
// outputs:
// object(DibiRow)#3 (3) {
// customer_id => int(1)

View File

@ -4,7 +4,7 @@
<?php
require_once 'Nette/Debug.php';
require_once 'Nette/Debugger.php';
require_once '../dibi/dibi.php';
date_default_timezone_set('Europe/Prague');

View File

@ -4,7 +4,7 @@
<?php
require_once 'Nette/Debug.php';
require_once 'Nette/Debugger.php';
require_once '../dibi/dibi.php';
@ -27,4 +27,4 @@ function DibiResult_prototype_fetchShuffle(DibiResult $obj)
// fetch complete result set shuffled
$res = dibi::query('SELECT * FROM [customers]');
$all = $res->fetchShuffle();
Debug::dump($all);
Debugger::dump($all);

View File

@ -4,7 +4,7 @@
<?php
require_once 'Nette/Debug.php';
require_once 'Nette/Debugger.php';
require_once '../dibi/dibi.php';
date_default_timezone_set('Europe/Prague');

View File

@ -4,7 +4,7 @@
<?php
require_once 'Nette/Debug.php';
require_once 'Nette/Debugger.php';
require_once '../dibi/dibi.php';

View File

@ -4,7 +4,7 @@
<?php
require_once 'Nette/Debug.php';
require_once 'Nette/Debugger.php';
require_once '../dibi/dibi.php';
date_default_timezone_set('Europe/Prague');

View File

@ -6,7 +6,7 @@
<?php
require_once 'Nette/Debug.php';
require_once 'Nette/Debugger.php';
require_once '../dibi/dibi.php';

View File

@ -4,7 +4,7 @@
<?php
require_once 'Nette/Debug.php';
require_once 'Nette/Debugger.php';
require_once '../dibi/dibi.php';

View File

@ -4,7 +4,7 @@
<?php
require_once 'Nette/Debug.php';
require_once 'Nette/Debugger.php';
require_once '../dibi/dibi.php';