本文整理匯總了PHP中dibi::getProfiler方法的典型用法代碼示例。如果您正苦於以下問題:PHP dibi::getProfiler方法的具體用法?PHP dibi::getProfiler怎麽用?PHP dibi::getProfiler使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類dibi
的用法示例。
在下文中一共展示了dibi::getProfiler方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: connect
public static function connect($settings = array(), $connection_name = null)
{
$config = Environment::getConfig();
foreach ($config['database'] as $connection_name => $settings) {
try {
dibi::connect($settings, $connection_name);
if ($settings['profiler'] == true) {
dibi::getProfiler()->setFile(APP_DIR . '/log/db.txt');
}
} catch (DibiException $e) {
echo get_class($e), ': ', $e->getMessage(), "\n";
}
}
}
示例2: date_default_timezone_set
<h1>dibi logger example</h1>
<?php
require_once 'Nette/Debug.php';
require_once '../dibi/dibi.php';
date_default_timezone_set('Europe/Prague');
dibi::connect(array('driver' => 'sqlite', 'database' => 'sample.sdb', 'profiler' => TRUE));
// enable log to this file
dibi::getProfiler()->setFile('log.sql');
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 '<p>', get_class($e), ': ', $e->getMessage(), '</p>';
}
echo "<h2>File log.sql:</h2>";
echo '<pre>', file_get_contents('log.sql'), '</pre>';
示例3: date_default_timezone_set
<!DOCTYPE html><link rel="stylesheet" href="data/style.css">
<h1>Using Logger | dibi</h1>
<?php
require_once 'Nette/Debug.php';
require_once '../dibi/dibi.php';
date_default_timezone_set('Europe/Prague');
dibi::connect(array('driver' => 'sqlite', 'database' => 'data/sample.sdb', 'profiler' => TRUE));
// enable query logging to this file
dibi::getProfiler()->setFile('data/log.sql');
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 '<p>', get_class($e), ': ', $e->getMessage(), '</p>';
}
// outputs a log file
echo "<h2>File data/log.sql:</h2>";
echo '<pre>', file_get_contents('data/log.sql'), '</pre>';