当前位置: 首页>>代码示例>>PHP>>正文


PHP ORM::_last_query方法代码示例

本文整理汇总了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;
 }
开发者ID:salvacam,项目名称:todo_list,代码行数:53,代码来源:idiorm.php

示例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;
 }
开发者ID:sirvan3tr,项目名称:testfi123,代码行数:29,代码来源:idiorm.php

示例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;
 }
开发者ID:neevan1e,项目名称:Done,代码行数:35,代码来源:idiorm.php


注:本文中的ORM::_last_query方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。