本文整理汇总了PHP中Fisharebest\Webtrees\Database::logQuery方法的典型用法代码示例。如果您正苦于以下问题:PHP Database::logQuery方法的具体用法?PHP Database::logQuery怎么用?PHP Database::logQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Fisharebest\Webtrees\Database
的用法示例。
在下文中一共展示了Database::logQuery方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* Execute a query
*
* @param array $bind_variables
*
* @throws \Exception
*
* @return Statement
*/
public function execute($bind_variables = array())
{
if ($this->executed) {
throw new \Exception('Statement::execute() called twice.');
}
// Parameters may be either named (e.g. :foo) or positional (e.g. ?).
// Named parameters may take any type. Positional parameters are always strings.
// Queries should use one format or the other.
foreach ($bind_variables as $key => $bind_variable) {
if (is_numeric($key)) {
// Positional parameters are numeric (starting at 1)
$key = 1 + $key;
} else {
// Named parameters are prefixed with a colon
$key = ':' . $key;
}
switch (gettype($bind_variable)) {
case 'NULL':
$this->pdo_statement->bindValue($key, $bind_variable, PDO::PARAM_NULL);
break;
case 'boolean':
$this->pdo_statement->bindValue($key, (int) $bind_variable, PDO::PARAM_INT);
break;
case 'integer':
$this->pdo_statement->bindValue($key, $bind_variable, PDO::PARAM_INT);
break;
default:
$this->pdo_statement->bindValue($key, $bind_variable, PDO::PARAM_STR);
break;
}
}
$start = microtime(true);
$this->pdo_statement->execute();
$end = microtime(true);
// If it was a SELECT statement, we cannot run it again.
$this->executed = strpos($this->pdo_statement->queryString, 'SELECT') === 0;
Database::logQuery($this->pdo_statement->queryString, $this->pdo_statement->rowCount(), $end - $start, $bind_variables);
return $this;
}