mirror of
https://github.com/dg/dibi.git
synced 2025-01-17 14:18:25 +01:00
tests: Nette\Debugger replaced with Tracy, examples requires PHP 5.3
This commit is contained in:
parent
abd3e2116c
commit
f31d4a9afa
1
examples/.gitignore
vendored
1
examples/.gitignore
vendored
@ -1,3 +1,4 @@
|
||||
_test.bat
|
||||
ref
|
||||
output
|
||||
log
|
File diff suppressed because one or more lines are too long
@ -1,3 +0,0 @@
|
||||
This file is part of Nette Framework
|
||||
|
||||
For more information please see http://nette.org
|
@ -1,3 +1,6 @@
|
||||
Tracy - PHP debugger, see http://tracy.nette.org
|
||||
|
||||
|
||||
Licenses
|
||||
========
|
||||
|
BIN
examples/Tracy/tracy.phar
Normal file
BIN
examples/Tracy/tracy.phar
Normal file
Binary file not shown.
@ -4,8 +4,7 @@
|
||||
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/Nette/Debugger.php';
|
||||
require dirname(__FILE__) . '/../dibi/dibi.php';
|
||||
require __DIR__ . '/../dibi/dibi.php';
|
||||
|
||||
|
||||
// connects to SQlite using dibi class
|
||||
@ -79,7 +78,7 @@ try {
|
||||
'driver' => 'odbc',
|
||||
'username' => 'root',
|
||||
'password' => '***',
|
||||
'dsn' => 'Driver={Microsoft Access Driver (*.mdb)};Dbq='.dirname(__FILE__).'/data/sample.mdb',
|
||||
'dsn' => 'Driver={Microsoft Access Driver (*.mdb)};Dbq='.__DIR__.'/data/sample.mdb',
|
||||
));
|
||||
echo 'OK';
|
||||
|
||||
|
@ -41,24 +41,24 @@ table.dump th {
|
||||
}
|
||||
|
||||
/* dump() */
|
||||
pre.nette-dump, pre.dump {
|
||||
pre.tracy-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 {
|
||||
pre.tracy-dump .php-array, pre.tracy-dump .php-object {
|
||||
color: #C22;
|
||||
}
|
||||
pre.nette-dump .php-string {
|
||||
pre.tracy-dump .php-string {
|
||||
color: #080;
|
||||
}
|
||||
pre.nette-dump .php-int, pre.nette-dump .php-float {
|
||||
pre.tracy-dump .php-int, pre.tracy-dump .php-float {
|
||||
color: #37D;
|
||||
}
|
||||
pre.nette-dump .php-null, pre.nette-dump .php-bool {
|
||||
pre.tracy-dump .php-null, pre.tracy-dump .php-bool {
|
||||
color: black;
|
||||
}
|
||||
pre.nette-dump .php-visibility {
|
||||
pre.tracy-dump .php-visibility {
|
||||
font-size: 85%; color: #999;
|
||||
}
|
||||
|
@ -4,8 +4,7 @@
|
||||
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/Nette/Debugger.php';
|
||||
require dirname(__FILE__) . '/../dibi/dibi.php';
|
||||
require __DIR__ . '/../dibi/dibi.php';
|
||||
|
||||
|
||||
dibi::connect(array(
|
||||
|
@ -4,8 +4,7 @@
|
||||
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/Nette/Debugger.php';
|
||||
require dirname(__FILE__) . '/../dibi/dibi.php';
|
||||
require __DIR__ . '/../dibi/dibi.php';
|
||||
|
||||
|
||||
dibi::connect(array(
|
||||
|
@ -4,10 +4,11 @@
|
||||
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/Nette/Debugger.php';
|
||||
require dirname(__FILE__) . '/../dibi/dibi.php';
|
||||
require __DIR__ . '/Tracy/tracy.phar';
|
||||
require __DIR__ . '/../dibi/dibi.php';
|
||||
|
||||
Tracy\Debugger::enable();
|
||||
|
||||
ndebug();
|
||||
|
||||
dibi::connect(array(
|
||||
'driver' => 'sqlite3',
|
||||
@ -30,40 +31,40 @@ product_id | title
|
||||
// fetch a single row
|
||||
echo "<h2>fetch()</h2>\n";
|
||||
$row = dibi::fetch('SELECT title FROM products');
|
||||
dump($row); // Chair
|
||||
Tracy\Dumper::dump($row); // Chair
|
||||
|
||||
|
||||
// fetch a single value
|
||||
echo "<h2>fetchSingle()</h2>\n";
|
||||
$value = dibi::fetchSingle('SELECT title FROM products');
|
||||
dump($value); // Chair
|
||||
Tracy\Dumper::dump($value); // Chair
|
||||
|
||||
|
||||
// fetch complete result set
|
||||
echo "<h2>fetchAll()</h2>\n";
|
||||
$all = dibi::fetchAll('SELECT * FROM products');
|
||||
dump($all);
|
||||
Tracy\Dumper::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
|
||||
dump($assoc);
|
||||
Tracy\Dumper::dump($assoc);
|
||||
|
||||
|
||||
// fetch complete result set like pairs key => value
|
||||
echo "<h2>fetchPairs('product_id', 'title')</h2>\n";
|
||||
$res = dibi::query('SELECT * FROM products');
|
||||
$pairs = $res->fetchPairs('product_id', 'title');
|
||||
dump($pairs);
|
||||
Tracy\Dumper::dump($pairs);
|
||||
|
||||
|
||||
// fetch row by row
|
||||
echo "<h2>using foreach</h2>\n";
|
||||
$res = dibi::query('SELECT * FROM products');
|
||||
foreach ($res as $n => $row) {
|
||||
dump($row);
|
||||
Tracy\Dumper::dump($row);
|
||||
}
|
||||
|
||||
|
||||
@ -77,14 +78,14 @@ $res = dibi::query('
|
||||
|
||||
echo "<h2>fetchAssoc('name|title')</h2>\n";
|
||||
$assoc = $res->fetchAssoc('name|title'); // key
|
||||
dump($assoc);
|
||||
Tracy\Dumper::dump($assoc);
|
||||
|
||||
echo "<h2>fetchAssoc('name[]title')</h2>\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);
|
||||
Tracy\Dumper::dump($assoc);
|
||||
|
||||
echo "<h2>fetchAssoc('name->title')</h2>\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);
|
||||
Tracy\Dumper::dump($assoc);
|
||||
|
@ -4,8 +4,7 @@
|
||||
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/Nette/Debugger.php';
|
||||
require dirname(__FILE__) . '/../dibi/dibi.php';
|
||||
require __DIR__ . '/../dibi/dibi.php';
|
||||
|
||||
|
||||
dibi::connect(array(
|
||||
|
@ -1,32 +0,0 @@
|
||||
<!DOCTYPE html><link rel="stylesheet" href="data/style.css">
|
||||
|
||||
<style> html { background: url(data/arrow.png) no-repeat bottom right; height: 100%; } </style>
|
||||
|
||||
<h1>Nette Debugger & Variables | dibi</h1>
|
||||
|
||||
<p>Dibi can dump variables via Nette Debugger, part of Nette Framework.</p>
|
||||
|
||||
<ul>
|
||||
<li>Nette Framework: http://nette.org
|
||||
</ul>
|
||||
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/Nette/Debugger.php';
|
||||
require dirname(__FILE__) . '/../dibi/dibi.php';
|
||||
|
||||
|
||||
// enable Nette Debugger
|
||||
NDebugger::enable();
|
||||
|
||||
|
||||
dibi::connect(array(
|
||||
'driver' => 'sqlite3',
|
||||
'database' => 'data/sample.s3db',
|
||||
'profiler' => array(
|
||||
'run' => TRUE,
|
||||
)
|
||||
));
|
||||
|
||||
|
||||
NDebugger::barDump( dibi::fetchAll('SELECT * FROM customers WHERE customer_id < ?', 38), '[customers]' );
|
@ -4,8 +4,7 @@
|
||||
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/Nette/Debugger.php';
|
||||
require dirname(__FILE__) . '/../dibi/dibi.php';
|
||||
require __DIR__ . '/../dibi/dibi.php';
|
||||
|
||||
|
||||
dibi::connect(array(
|
||||
|
@ -4,8 +4,7 @@
|
||||
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/Nette/Debugger.php';
|
||||
require dirname(__FILE__) . '/../dibi/dibi.php';
|
||||
require __DIR__ . '/../dibi/dibi.php';
|
||||
|
||||
date_default_timezone_set('Europe/Prague');
|
||||
|
||||
|
@ -1,13 +1,14 @@
|
||||
<!DOCTYPE html><link rel="stylesheet" href="data/style.css">
|
||||
|
||||
<h1>Result Set Data Types | dibi</h1>
|
||||
<h1>Result Set Data Types | dibi</h1>
|
||||
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/Nette/Debugger.php';
|
||||
require dirname(__FILE__) . '/../dibi/dibi.php';
|
||||
require __DIR__ . '/Tracy/tracy.phar';
|
||||
require __DIR__ . '/../dibi/dibi.php';
|
||||
|
||||
Tracy\Debugger::enable();
|
||||
|
||||
ndebug();
|
||||
date_default_timezone_set('Europe/Prague');
|
||||
|
||||
|
||||
@ -25,7 +26,7 @@ $res->setType('customer_id', Dibi::INTEGER)
|
||||
->setFormat(dibi::DATETIME, 'Y-m-d H:i:s');
|
||||
|
||||
|
||||
dump( $res->fetch() );
|
||||
Tracy\Dumper::dump( $res->fetch() );
|
||||
// outputs:
|
||||
// DibiRow(3) {
|
||||
// customer_id => 1
|
||||
@ -36,7 +37,7 @@ dump( $res->fetch() );
|
||||
// using auto-detection (works well with MySQL or other strictly typed databases)
|
||||
$res = dibi::query('SELECT * FROM [customers]');
|
||||
|
||||
dump( $res->fetch() );
|
||||
Tracy\Dumper::dump( $res->fetch() );
|
||||
// outputs:
|
||||
// DibiRow(3) {
|
||||
// customer_id => 1
|
||||
|
@ -1,21 +1,20 @@
|
||||
<!DOCTYPE html><link rel="stylesheet" href="data/style.css">
|
||||
|
||||
<h1>Nette Debugger & SQL Exceptions | dibi</h1>
|
||||
<h1>Tracy & SQL Exceptions | dibi</h1>
|
||||
|
||||
<p>Dibi can display and log exceptions via Nette Debugger, part of Nette Framework.</p>
|
||||
<p>Dibi can display and log exceptions via Tracy, part of Nette Framework.</p>
|
||||
|
||||
<ul>
|
||||
<li>Nette Framework: http://nette.org
|
||||
<li>Tracy Debugger: http://tracy.nette.org
|
||||
</ul>
|
||||
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/Nette/Debugger.php';
|
||||
require dirname(__FILE__) . '/../dibi/dibi.php';
|
||||
require __DIR__ . '/Tracy/tracy.phar';
|
||||
require __DIR__ . '/../dibi/dibi.php';
|
||||
|
||||
|
||||
// enable Nette Debugger
|
||||
ndebug();
|
||||
Tracy\Debugger::enable();
|
||||
|
||||
|
||||
dibi::connect(array(
|
31
examples/tracy-and-variables.php
Normal file
31
examples/tracy-and-variables.php
Normal file
@ -0,0 +1,31 @@
|
||||
<!DOCTYPE html><link rel="stylesheet" href="data/style.css">
|
||||
|
||||
<style> html { background: url(data/arrow.png) no-repeat bottom right; height: 100%; } </style>
|
||||
|
||||
<h1>Tracy & Variables | dibi</h1>
|
||||
|
||||
<p>Dibi can dump variables via Tracy, part of Nette Framework.</p>
|
||||
|
||||
<ul>
|
||||
<li>Tracy Debugger: http://tracy.nette.org
|
||||
</ul>
|
||||
|
||||
<?php
|
||||
|
||||
require __DIR__ . '/Tracy/tracy.phar';
|
||||
require __DIR__ . '/../dibi/dibi.php';
|
||||
|
||||
|
||||
Tracy\Debugger::enable();
|
||||
|
||||
|
||||
dibi::connect(array(
|
||||
'driver' => 'sqlite3',
|
||||
'database' => 'data/sample.s3db',
|
||||
'profiler' => array(
|
||||
'run' => TRUE,
|
||||
)
|
||||
));
|
||||
|
||||
|
||||
Tracy\Debugger::barDump( dibi::fetchAll('SELECT * FROM customers WHERE customer_id < ?', 38), '[customers]' );
|
@ -4,8 +4,7 @@
|
||||
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/Nette/Debugger.php';
|
||||
require dirname(__FILE__) . '/../dibi/dibi.php';
|
||||
require __DIR__ . '/../dibi/dibi.php';
|
||||
|
||||
date_default_timezone_set('Europe/Prague');
|
||||
|
||||
|
@ -4,10 +4,11 @@
|
||||
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/Nette/Debugger.php';
|
||||
require dirname(__FILE__) . '/../dibi/dibi.php';
|
||||
require __DIR__ . '/Tracy/tracy.phar';
|
||||
require __DIR__ . '/../dibi/dibi.php';
|
||||
|
||||
Tracy\Debugger::enable();
|
||||
|
||||
ndebug();
|
||||
|
||||
dibi::connect(array(
|
||||
'driver' => 'sqlite3',
|
||||
@ -27,4 +28,4 @@ function DibiResult_prototype_fetchShuffle(DibiResult $obj)
|
||||
// fetch complete result set shuffled
|
||||
$res = dibi::query('SELECT * FROM [customers]');
|
||||
$all = $res->fetchShuffle();
|
||||
dump($all);
|
||||
Tracy\Dumper::dump($all);
|
||||
|
@ -4,8 +4,7 @@
|
||||
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/Nette/Debugger.php';
|
||||
require dirname(__FILE__) . '/../dibi/dibi.php';
|
||||
require __DIR__ . '/../dibi/dibi.php';
|
||||
|
||||
date_default_timezone_set('Europe/Prague');
|
||||
|
||||
|
@ -4,8 +4,7 @@
|
||||
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/Nette/Debugger.php';
|
||||
require dirname(__FILE__) . '/../dibi/dibi.php';
|
||||
require __DIR__ . '/../dibi/dibi.php';
|
||||
|
||||
|
||||
dibi::connect(array(
|
||||
|
@ -4,8 +4,7 @@
|
||||
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/Nette/Debugger.php';
|
||||
require dirname(__FILE__) . '/../dibi/dibi.php';
|
||||
require __DIR__ . '/../dibi/dibi.php';
|
||||
|
||||
date_default_timezone_set('Europe/Prague');
|
||||
|
||||
|
@ -6,8 +6,7 @@
|
||||
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/Nette/Debugger.php';
|
||||
require dirname(__FILE__) . '/../dibi/dibi.php';
|
||||
require __DIR__ . '/../dibi/dibi.php';
|
||||
|
||||
|
||||
dibi::connect(array(
|
||||
|
@ -4,8 +4,7 @@
|
||||
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/Nette/Debugger.php';
|
||||
require dirname(__FILE__) . '/../dibi/dibi.php';
|
||||
require __DIR__ . '/../dibi/dibi.php';
|
||||
|
||||
|
||||
dibi::connect(array(
|
||||
|
@ -4,8 +4,7 @@
|
||||
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/Nette/Debugger.php';
|
||||
require dirname(__FILE__) . '/../dibi/dibi.php';
|
||||
require __DIR__ . '/../dibi/dibi.php';
|
||||
|
||||
|
||||
dibi::connect(array(
|
||||
|
Loading…
x
Reference in New Issue
Block a user