1
0
mirror of https://github.com/dg/dibi.git synced 2025-02-22 18:02:25 +01:00
php-dibi/examples/logger.php

33 lines
719 B
PHP
Raw Normal View History

<h1>dibi logger example</h1>
2006-06-04 23:06:33 +00:00
<?php
require_once '../dibi/dibi.php';
// enable log to this file, TRUE means "log all queries"
dibi::startLogger('log.sql', TRUE);
2006-06-04 23:06:33 +00:00
2006-06-04 23:06:33 +00:00
dibi::connect(array(
'driver' => 'sqlite',
'database' => 'sample.sdb',
2006-06-04 23:06:33 +00:00
));
try {
$res = dibi::query('SELECT * FROM [customers] WHERE [customer_id] = %i', 1);
$res = dibi::query('SELECT * FROM [customers] WHERE [customer_id] < %i', 5);
2006-06-04 23:06:33 +00:00
$res = dibi::query('SELECT FROM [customers] WHERE [customer_id] < %i', 38);
2006-06-04 23:06:33 +00:00
} catch (DibiException $e) {
2007-11-11 04:59:39 +00:00
echo '<p>', get_class($e), ': ', $e->getMessage(), '</p>';
}
2006-06-04 23:06:33 +00:00
echo "<h2>File log.sql:</h2>";
2006-06-04 23:06:33 +00:00
echo '<pre>', file_get_contents('log.sql'), '</pre>';