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:
File diff suppressed because one or more lines are too long
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once 'Nette/Debug.php';
|
require_once 'Nette/Debugger.php';
|
||||||
require_once '../dibi/dibi.php';
|
require_once '../dibi/dibi.php';
|
||||||
|
|
||||||
|
|
||||||
|
@@ -16,12 +16,6 @@ h2 {
|
|||||||
font-size: 150%;
|
font-size: 150%;
|
||||||
}
|
}
|
||||||
|
|
||||||
pre.dump {
|
|
||||||
border: 1px solid silver;
|
|
||||||
padding: 1em;
|
|
||||||
margin: 1em 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
a {
|
a {
|
||||||
color: #000080;
|
color: #000080;
|
||||||
}
|
}
|
||||||
@@ -45,3 +39,26 @@ table.dump th {
|
|||||||
color: #525b37;
|
color: #525b37;
|
||||||
background: #e3e9ba;
|
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;
|
||||||
|
}
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once 'Nette/Debug.php';
|
require_once 'Nette/Debugger.php';
|
||||||
require_once '../dibi/dibi.php';
|
require_once '../dibi/dibi.php';
|
||||||
|
|
||||||
|
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once 'Nette/Debug.php';
|
require_once 'Nette/Debugger.php';
|
||||||
require_once '../dibi/dibi.php';
|
require_once '../dibi/dibi.php';
|
||||||
|
|
||||||
|
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once 'Nette/Debug.php';
|
require_once 'Nette/Debugger.php';
|
||||||
require_once '../dibi/dibi.php';
|
require_once '../dibi/dibi.php';
|
||||||
|
|
||||||
|
|
||||||
@@ -29,38 +29,38 @@ product_id | title
|
|||||||
// fetch a single row
|
// fetch a single row
|
||||||
echo "<h2>fetch()</h2>\n";
|
echo "<h2>fetch()</h2>\n";
|
||||||
$row = dibi::fetch('SELECT title FROM products');
|
$row = dibi::fetch('SELECT title FROM products');
|
||||||
Debug::dump($row); // Chair
|
Debugger::dump($row); // Chair
|
||||||
|
|
||||||
|
|
||||||
// fetch a single value
|
// fetch a single value
|
||||||
echo "<h2>fetchSingle()</h2>\n";
|
echo "<h2>fetchSingle()</h2>\n";
|
||||||
$value = dibi::fetchSingle('SELECT title FROM products');
|
$value = dibi::fetchSingle('SELECT title FROM products');
|
||||||
Debug::dump($value); // Chair
|
Debugger::dump($value); // Chair
|
||||||
|
|
||||||
|
|
||||||
// fetch complete result set
|
// fetch complete result set
|
||||||
echo "<h2>fetchAll()</h2>\n";
|
echo "<h2>fetchAll()</h2>\n";
|
||||||
$all = dibi::fetchAll('SELECT * FROM products');
|
$all = dibi::fetchAll('SELECT * FROM products');
|
||||||
Debug::dump($all);
|
Debugger::dump($all);
|
||||||
|
|
||||||
|
|
||||||
// fetch complete result set like association array
|
// fetch complete result set like association array
|
||||||
echo "<h2>fetchAssoc('title')</h2>\n";
|
echo "<h2>fetchAssoc('title')</h2>\n";
|
||||||
$res = dibi::query('SELECT * FROM products');
|
$res = dibi::query('SELECT * FROM products');
|
||||||
$assoc = $res->fetchAssoc('title'); // key
|
$assoc = $res->fetchAssoc('title'); // key
|
||||||
Debug::dump($assoc);
|
Debugger::dump($assoc);
|
||||||
|
|
||||||
|
|
||||||
// fetch complete result set like pairs key => value
|
// fetch complete result set like pairs key => value
|
||||||
echo "<h2>fetchPairs('product_id', 'title')</h2>\n";
|
echo "<h2>fetchPairs('product_id', 'title')</h2>\n";
|
||||||
$pairs = $res->fetchPairs('product_id', 'title');
|
$pairs = $res->fetchPairs('product_id', 'title');
|
||||||
Debug::dump($pairs);
|
Debugger::dump($pairs);
|
||||||
|
|
||||||
|
|
||||||
// fetch row by row
|
// fetch row by row
|
||||||
echo "<h2>using foreach</h2>\n";
|
echo "<h2>using foreach</h2>\n";
|
||||||
foreach ($res as $n => $row) {
|
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";
|
echo "<h2>fetchAssoc('customers.name|products.title')</h2>\n";
|
||||||
$assoc = $res->fetchAssoc('customers.name|products.title'); // key
|
$assoc = $res->fetchAssoc('customers.name|products.title'); // key
|
||||||
Debug::dump($assoc);
|
Debugger::dump($assoc);
|
||||||
|
|
||||||
echo "<h2>fetchAssoc('customers.name[]products.title')</h2>\n";
|
echo "<h2>fetchAssoc('customers.name[]products.title')</h2>\n";
|
||||||
$assoc = $res->fetchAssoc('customers.name[]products.title'); // key
|
$assoc = $res->fetchAssoc('customers.name[]products.title'); // key
|
||||||
Debug::dump($assoc);
|
Debugger::dump($assoc);
|
||||||
|
|
||||||
echo "<h2>fetchAssoc('customers.name->products.title')</h2>\n";
|
echo "<h2>fetchAssoc('customers.name->products.title')</h2>\n";
|
||||||
$assoc = $res->fetchAssoc('customers.name->products.title'); // key
|
$assoc = $res->fetchAssoc('customers.name->products.title'); // key
|
||||||
Debug::dump($assoc);
|
Debugger::dump($assoc);
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once 'Nette/Debug.php';
|
require_once 'Nette/Debugger.php';
|
||||||
require_once '../dibi/dibi.php';
|
require_once '../dibi/dibi.php';
|
||||||
|
|
||||||
|
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once 'Nette/Debug.php';
|
require_once 'Nette/Debugger.php';
|
||||||
require_once '../dibi/dibi.php';
|
require_once '../dibi/dibi.php';
|
||||||
|
|
||||||
|
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once 'Nette/Debug.php';
|
require_once 'Nette/Debugger.php';
|
||||||
require_once '../dibi/dibi.php';
|
require_once '../dibi/dibi.php';
|
||||||
|
|
||||||
date_default_timezone_set('Europe/Prague');
|
date_default_timezone_set('Europe/Prague');
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once 'Nette/Debug.php';
|
require_once 'Nette/Debugger.php';
|
||||||
require_once '../dibi/dibi.php';
|
require_once '../dibi/dibi.php';
|
||||||
|
|
||||||
date_default_timezone_set('Europe/Prague');
|
date_default_timezone_set('Europe/Prague');
|
||||||
@@ -22,7 +22,7 @@ $res = dibi::query('SELECT * FROM [customers]');
|
|||||||
$res->setType('customer_id', Dibi::INTEGER)
|
$res->setType('customer_id', Dibi::INTEGER)
|
||||||
->setType('added', Dibi::DATETIME, 'H:i j.n.Y');
|
->setType('added', Dibi::DATETIME, 'H:i j.n.Y');
|
||||||
|
|
||||||
Debug::dump( $res->fetch() );
|
Debugger::dump( $res->fetch() );
|
||||||
// outputs:
|
// outputs:
|
||||||
// object(DibiRow)#3 (3) {
|
// object(DibiRow)#3 (3) {
|
||||||
// customer_id => int(1)
|
// customer_id => int(1)
|
||||||
@@ -37,7 +37,7 @@ $res = dibi::query('SELECT * FROM [customers]');
|
|||||||
|
|
||||||
$res->detectTypes();
|
$res->detectTypes();
|
||||||
|
|
||||||
Debug::dump( $res->fetch() );
|
Debugger::dump( $res->fetch() );
|
||||||
// outputs:
|
// outputs:
|
||||||
// object(DibiRow)#3 (3) {
|
// object(DibiRow)#3 (3) {
|
||||||
// customer_id => int(1)
|
// customer_id => int(1)
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once 'Nette/Debug.php';
|
require_once 'Nette/Debugger.php';
|
||||||
require_once '../dibi/dibi.php';
|
require_once '../dibi/dibi.php';
|
||||||
|
|
||||||
date_default_timezone_set('Europe/Prague');
|
date_default_timezone_set('Europe/Prague');
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once 'Nette/Debug.php';
|
require_once 'Nette/Debugger.php';
|
||||||
require_once '../dibi/dibi.php';
|
require_once '../dibi/dibi.php';
|
||||||
|
|
||||||
|
|
||||||
@@ -27,4 +27,4 @@ function DibiResult_prototype_fetchShuffle(DibiResult $obj)
|
|||||||
// fetch complete result set shuffled
|
// fetch complete result set shuffled
|
||||||
$res = dibi::query('SELECT * FROM [customers]');
|
$res = dibi::query('SELECT * FROM [customers]');
|
||||||
$all = $res->fetchShuffle();
|
$all = $res->fetchShuffle();
|
||||||
Debug::dump($all);
|
Debugger::dump($all);
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once 'Nette/Debug.php';
|
require_once 'Nette/Debugger.php';
|
||||||
require_once '../dibi/dibi.php';
|
require_once '../dibi/dibi.php';
|
||||||
|
|
||||||
date_default_timezone_set('Europe/Prague');
|
date_default_timezone_set('Europe/Prague');
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once 'Nette/Debug.php';
|
require_once 'Nette/Debugger.php';
|
||||||
require_once '../dibi/dibi.php';
|
require_once '../dibi/dibi.php';
|
||||||
|
|
||||||
|
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once 'Nette/Debug.php';
|
require_once 'Nette/Debugger.php';
|
||||||
require_once '../dibi/dibi.php';
|
require_once '../dibi/dibi.php';
|
||||||
|
|
||||||
date_default_timezone_set('Europe/Prague');
|
date_default_timezone_set('Europe/Prague');
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once 'Nette/Debug.php';
|
require_once 'Nette/Debugger.php';
|
||||||
require_once '../dibi/dibi.php';
|
require_once '../dibi/dibi.php';
|
||||||
|
|
||||||
|
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once 'Nette/Debug.php';
|
require_once 'Nette/Debugger.php';
|
||||||
require_once '../dibi/dibi.php';
|
require_once '../dibi/dibi.php';
|
||||||
|
|
||||||
|
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once 'Nette/Debug.php';
|
require_once 'Nette/Debugger.php';
|
||||||
require_once '../dibi/dibi.php';
|
require_once '../dibi/dibi.php';
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user