1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-31 09:41:43 +02:00

* modified DibiException (getDbError, ...)

* fix dibi::dumpResult()
This commit is contained in:
David Grudl
2007-02-02 03:51:43 +00:00
parent a2b1036a66
commit 0c86515076
16 changed files with 218 additions and 138 deletions

View File

@@ -1,4 +1,3 @@
<pre>
<?php
require_once '../dibi/dibi.php';
@@ -19,26 +18,56 @@ dibi::$logMode = 'a';
dibi::$logAll = TRUE;
// mysql
// CHANGE TO REAL PARAMETERS!
dibi::connect(array(
'driver' => 'mysql',
'host' => 'localhost',
'username' => 'root',
'password' => 'xxx', // change to real password!
'database' => 'xxx',
'password' => 'xxx',
'database' => 'dibi',
'charset' => 'utf8',
));
$res = dibi::query('SELECT * FROM [nucleus_item] WHERE [inumber] = %i', 38);
// generate user-level errors
dibi::$throwExceptions = FALSE;
echo '<h1>User-level errors</h1>';
$res = dibi::query('SELECT * FROM [nucleus_item] WHERE [inumber] < %i', 38);
$res = dibi::query('SELECT * FROM [mytable] WHERE [inumber] = %i', 38);
$res = dibi::query('SELECT * FROM [*nucleus_item] WHERE [inumber] < %i', 38);
$res = dibi::query('SELECT * FROM [mytable] WHERE [inumber] < %i', 38);
echo 'See file ', dibi::$logFile;
?>
$res = dibi::query('SELECT FROM [mytable] WHERE [inumber] < %i', 38);
echo "<br />See file ", dibi::$logFile;
// generate DibiException
dibi::$throwExceptions = TRUE;
echo '<h1>DibiException</h1>';
try {
$res = dibi::query('SELECT FROM [mytable] WHERE [inumber] < %i', 38);
} catch (DibiException $e) {
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>';
}