本文整理汇总了PHP中WT_DB::logQuery方法的典型用法代码示例。如果您正苦于以下问题:PHP WT_DB::logQuery方法的具体用法?PHP WT_DB::logQuery怎么用?PHP WT_DB::logQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WT_DB
的用法示例。
在下文中一共展示了WT_DB::logQuery方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* Execute a query
*
* @param array $bind_variables
*
* @return WT_DBStatement
* @throws Exception
*/
public function execute($bind_variables = array())
{
if ($this->executed) {
throw new Exception('WT_DBStatement::execute() called twice.');
}
// Turn booleans into integers. Otherwise MySQL’s strict mode can get upset.
foreach ($bind_variables as &$bind_variable) {
if ($bind_variable === false) {
// Otherwise true=>'1' and false=>''
$bind_variable = 0;
}
}
$start = microtime(true);
$this->pdo_statement->execute($bind_variables);
$end = microtime(true);
// If it was a SELECT statement, we cannot run it again.
$this->executed = strpos($this->pdo_statement->queryString, 'SELECT') === 0;
WT_DB::logQuery($this->pdo_statement->queryString, $this->pdo_statement->rowCount(), $end - $start, $bind_variables);
return $this;
}
示例2: __call
public function __call($function, $params)
{
switch ($function) {
case 'closeCursor':
$this->executed = false;
// no break;
// no break;
case 'bindColumn':
case 'bindParam':
case 'bindValue':
// TODO: bind variables need to be stored in $this->bind_variables so we can log them
// TODO: bind variables need to be stored in $this->bind_variables so we can log them
case 'setAttribute':
case 'setFetchMode':
// Functions that return no values become fluent
call_user_func_array(array($this->pdostatement, $function), $params);
return $this;
case 'execute':
if ($this->executed) {
trigger_error('WT_DBStatement::execute() called twice.', E_USER_ERROR);
} else {
if ($params) {
$this->bind_variables = $params[0];
foreach ($params[0] as &$param) {
if ($param === false) {
// For consistency, otherwise true=>'1' and false=>''
$param = 0;
}
}
}
$start = microtime(true);
call_user_func_array(array($this->pdostatement, $function), $params);
$end = microtime(true);
$this->executed = !preg_match('/^(insert|delete|update|create|alter) /i', $this->pdostatement->queryString);
WT_DB::logQuery($this->pdostatement->queryString, $this->pdostatement->rowCount(), $end - $start, $this->bind_variables);
return $this;
}
case 'fetch':
case 'fetchColumn':
case 'fetchObject':
case 'fetchAll':
// Automatically execute the query
if (!$this->executed) {
$this->execute();
$this->executed = true;
}
// no break;
// no break;
default:
return call_user_func_array(array($this->pdostatement, $function), $params);
}
}