Пример #1
0
 /**
  * 事务查询
  * @param string $sql
  */
 protected function _query($sql)
 {
     try {
         if ($this->db_driver->query($sql, null, true)) {
             $status = true;
         } else {
             $status = false;
         }
     } catch (Exception $e) {
         $status = false;
     }
     return $status;
 }
Пример #2
0
 /**
  * 创建一个数据库
  *
  * @param string $database
  * @param string $charset 编码,不传则使用数据库连接配置相同到编码
  * @param string $collate 整理格式
  * @return boolean
  * @throws Exception
  */
 public function create_database($database, $charset = null, $collate = null)
 {
     if (method_exists($this->driver, 'create_database')) {
         return $this->driver->create_database($database, $charset, $collate);
     } else {
         return false;
     }
 }
Пример #3
0
 /**
  * 保存慢查询日志
  *
  * @param float $start_time 由 `$this->_start_slow_query()` 返回的值
  */
 protected function _record_slow_query($start_time)
 {
     if (!$start_time) {
         return;
     }
     $end_time = microtime(1);
     $use_time = 1000 * ($end_time - $start_time);
     if (($min_time = Database::_get_slow_query_setting_time()) && $use_time > $min_time) {
         // 记录慢查询
         Database::$slow_querys[] = array($start_time, $use_time, $this->driver->last_query());
     }
 }