1
0
mirror of https://github.com/dg/dibi.git synced 2025-09-01 10:02:53 +02:00

* removed $throwExceptions (always throws)

* added DibiLogger, dibi::notify(), dibi::startLogger()
* miniprofiler dibi::$numOfQueries, $totalTime, $elapsedTime
* simplified DibiException, added DibiDatabaseException
* Dibi::nativeQuery splitted into DibiDriver::doQuery & nativeQuery()
* moved dibi::dumpResult -> DibiResult::dump()
* moved dibi::test() -> DibiDriver::test()
* DibiTranslator generates $mask
This commit is contained in:
David Grudl
2007-09-29 07:53:25 +00:00
parent 0d8478d1d3
commit d35a850311
26 changed files with 689 additions and 703 deletions

View File

@@ -1,21 +1,10 @@
<h1>dibi logger example</h1>
<?php
require_once '../dibi/dibi.php';
// required since PHP 5.1.0
if (function_exists('date_default_timezone_set'))
date_default_timezone_set('Europe/Prague'); // or 'GMT'
// enable log to this file
dibi::$logFile = 'log.sql';
// append mode
dibi::$logMode = 'a';
// log all queries
dibi::$logAll = TRUE;
// enable log to this file, TRUE means "log all queries"
dibi::startLogger('log.sql', TRUE);
@@ -26,43 +15,20 @@ dibi::connect(array(
// generate user-level errors
dibi::$throwExceptions = FALSE;
echo '<h1>User-level errors</h1>';
$res = dibi::query('SELECT * FROM [customers] WHERE [customer_id] = %i', 1);
$res = dibi::query('SELECT * FROM [customers] WHERE [customer_id] < %i', 5);
$res = dibi::query('SELECT FROM [customers] WHERE [customer_id] < %i', 5);
echo "<br />See file ", dibi::$logFile;
// generate DibiException
dibi::$throwExceptions = TRUE;
echo '<h1>DibiException</h1>';
try {
$res = dibi::query('SELECT * FROM [customers] WHERE [customer_id] = %i', 1);
$res = dibi::query('SELECT * FROM [customers] WHERE [customer_id] < %i', 5);
$res = dibi::query('SELECT FROM [customers] WHERE [customer_id] < %i', 38);
} catch (DibiException $e) {
echo '<h2>Dibi Exception:</h2>';
echo '<pre>', $e, '</pre>';
}
echo '<h2>$e->getSql()</h2>';
$sql = $e->getSql();
echo "SQL: $sql\n";
echo '<h2>$e->getDbError()</h2>';
$error = $e->getDbError();
echo '<pre>';
print_r($error);
echo '</pre>';
echo "<h2>File log.sql:</h2>";
}
echo '<pre>', file_get_contents('log.sql'), '</pre>';