本文整理汇总了PHP中ORM::_last_query方法的典型用法代码示例。如果您正苦于以下问题:PHP ORM::_last_query方法的具体用法?PHP ORM::_last_query怎么用?PHP ORM::_last_query使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ORM
的用法示例。
在下文中一共展示了ORM::_last_query方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _log_query
/**
* Add a query to the internal query log. Only works if the
* 'logging' config option is set to true.
*
* This works by manually binding the parameters to the query - the
* query isn't executed like this (PDO normally passes the query and
* parameters to the database which takes care of the binding) but
* doing it this way makes the logged queries more readable.
* @param string $query
* @param array $parameters An array of parameters to be bound in to the query
* @param string $connection_name Which connection to use
* @param float $query_time Query time
* @return bool
*/
protected static function _log_query($query, $parameters, $connection_name, $query_time)
{
// If logging is not enabled, do nothing
if (!self::$_config[$connection_name]['logging']) {
return false;
}
if (!isset(self::$_query_log[$connection_name])) {
self::$_query_log[$connection_name] = array();
}
// Strip out any non-integer indexes from the parameters
foreach ($parameters as $key => $value) {
if (!is_int($key)) {
unset($parameters[$key]);
}
}
if (count($parameters) > 0) {
// Escape the parameters
$parameters = array_map(array(self::get_db($connection_name), 'quote'), $parameters);
// Avoid %format collision for vsprintf
$query = str_replace("%", "%%", $query);
// Replace placeholders in the query for vsprintf
if (false !== strpos($query, "'") || false !== strpos($query, '"')) {
$query = IdiormString::str_replace_outside_quotes("?", "%s", $query);
} else {
$query = str_replace("?", "%s", $query);
}
// Replace the question marks in the query with the parameters
$bound_query = vsprintf($query, $parameters);
} else {
$bound_query = $query;
}
self::$_last_query = $bound_query;
self::$_query_log[$connection_name][] = $bound_query;
if (is_callable(self::$_config[$connection_name]['logger'])) {
$logger = self::$_config[$connection_name]['logger'];
$logger($bound_query, $query_time);
}
return true;
}
示例2: _log_query
/**
* Add a query to the internal query log. Only works if the
* 'logging' config option is set to true.
*
* This works by manually binding the parameters to the query - the
* query isn't executed like this (PDO normally passes the query and
* parameters to the database which takes care of the binding) but
* doing it this way makes the logged queries more readable.
*/
protected static function _log_query($query, $parameters)
{
// If logging is not enabled, do nothing
if (!self::$_config['logging']) {
return false;
}
if (count($parameters) > 0) {
// Escape the parameters
$parameters = array_map(array(self::$_db, 'quote'), $parameters);
// Replace placeholders in the query for vsprintf
$query = str_replace("?", "%s", $query);
// Replace the question marks in the query with the parameters
$bound_query = vsprintf($query, $parameters);
} else {
$bound_query = $query;
}
self::$_last_query = $bound_query;
self::$_query_log[] = $bound_query;
return true;
}
示例3: _log_query
/**
* Add a query to the internal query log. Only works if the
* 'logging' config option is set to true.
*
* This works by manually binding the parameters to the query - the
* query isn't executed like this (PDO normally passes the query and
* parameters to the database which takes care of the binding) but
* doing it this way makes the logged queries more readable.
*/
protected static function _log_query($query, $parameters)
{
// If logging is not enabled, do nothing
if (!self::$_config['logging']) {
return false;
}
if (count($parameters) > 0) {
// Escape the parameters
$parameters = array_map(array(self::$_db, 'quote'), $parameters);
// Avoid %format collision for vsprintf
$query = str_replace("%", "%%", $query);
// Replace placeholders in the query for vsprintf
if (false !== strpos($query, "'") || false !== strpos($query, '"')) {
$query = IdiormString::str_replace_outside_quotes("?", "%s", $query);
} else {
$query = str_replace("?", "%s", $query);
}
// Replace the question marks in the query with the parameters
$bound_query = vsprintf($query, $parameters);
} else {
$bound_query = $query;
}
self::$_last_query = $bound_query;
self::$_query_log[] = $bound_query;
return true;
}