Exemplo n.º 1
0
 function execute($params = null)
 {
     if ($this->count) {
         Trace::groups('DB')->group('count')->set(Trace::groups('DB')->group('count')->get() + 1);
     }
     if ($this->debug) {
         Benchmark::start('sql');
         $result = $this->stmt->execute($params);
         //Trace::groups('Data')->group('')->set($this->stmt->queryString);
         $bm = Benchmark::stop('sql', true);
         if ($bm['time'] >= $this->slow) {
             Trace::groups('DB')->group('query')->group($this->stmt->queryString)->group()->set(array('sql' => $this->stmt->queryString, 'values' => $params ? $params : $this->values, 'benchmark' => $bm));
             Trace::groups('DB')->group('sql_time')->set(Trace::groups('DB')->group('sql_time')->get() + $bm['time']);
             Trace::groups('DB')->group('slow_count')->set(Trace::groups('DB')->group('slow_count')->get() + 1);
         }
     } else {
         $result = $this->stmt->execute($params);
     }
     return $result;
 }
Exemplo n.º 2
0
Arquivo: DB.php Projeto: boolive/core
 /**
  * Выполнение запроса с выборками
  * @link http://www.php.net/manual/en/pdo.query.php
  * @param string $sql Строка SQL запроса
  * @return \PDOStatement
  */
 function query($sql)
 {
     if ($this->trace_count) {
         Trace::groups('DB')->group('count')->set(Trace::groups('DB')->group('count')->get() + 1);
     }
     if ($this->trace_sql) {
         Benchmark::start('sql');
         $sql = $this->AddPrefixes($sql);
         $result = parent::query($sql);
         $bm = Benchmark::stop('sql', true);
         if ($bm['time'] >= $this->slow_query) {
             Trace::groups('DB')->group('query')->group()->set(array('sql' => $sql, 'benchmark' => $bm));
             Trace::groups('DB')->group('sql_time')->set(Trace::groups('DB')->group('sql_time')->get() + $bm['time']);
             Trace::groups('DB')->group('slow_count')->set(Trace::groups('DB')->group('slow_count')->get() + 1);
         }
         return $result;
     }
     return parent::query($this->addPrefixes($sql));
 }