本文整理匯總了PHP中Piwik\Db::enableQueryLog方法的典型用法代碼示例。如果您正苦於以下問題:PHP Db::enableQueryLog方法的具體用法?PHP Db::enableQueryLog怎麽用?PHP Db::enableQueryLog使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Piwik\Db
的用法示例。
在下文中一共展示了Db::enableQueryLog方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: write
protected function write(array $record)
{
$sql = sprintf('INSERT INTO %s (tag, timestamp, level, message) VALUES (?, ?, ?, ?)', Common::prefixTable('logger_message'));
$queryLog = Db::isQueryLogEnabled();
Db::enableQueryLog(false);
Db::query($sql, array($record['extra']['class'], $record['datetime']->format('Y-m-d H:i:s'), $record['level_name'], trim($record['formatted'])));
Db::enableQueryLog($queryLog);
}
示例2: checkBackend
private function checkBackend($backend, $expectedMessage, $formatMessage = false, $tag = false)
{
if ($formatMessage) {
$expectedMessage = sprintf(self::STRING_MESSAGE_FORMAT_SPRINTF, $tag, $expectedMessage);
}
if ($backend == 'file') {
$this->assertTrue(file_exists(self::getLogFileLocation()));
$fileContents = file_get_contents(self::getLogFileLocation());
$fileContents = $this->removePathsFromBacktrace($fileContents);
$this->assertEquals($expectedMessage . "\n", $fileContents);
} else {
if ($backend == 'database') {
$queryLog = Db::isQueryLogEnabled();
Db::enableQueryLog(false);
$count = Db::fetchOne("SELECT COUNT(*) FROM " . Common::prefixTable('logger_message'));
$this->assertEquals(1, $count);
$message = Db::fetchOne("SELECT message FROM " . Common::prefixTable('logger_message') . " LIMIT 1");
$message = $this->removePathsFromBacktrace($message);
$this->assertEquals($expectedMessage, $message);
$tagInDb = Db::fetchOne("SELECT tag FROM " . Common::prefixTable('logger_message') . " LIMIT 1");
if ($tag === false) {
$this->assertEmpty($tagInDb);
} else {
$this->assertEquals($tag, $tagInDb);
}
Db::enableQueryLog($queryLog);
}
}
}