Esempio n. 1
1
 /**
  * Creates a PDO object and connects to the database.
  *
  * @return void
  * @throws \mysqli_sql_exception
  */
 protected function _connect()
 {
     if ($this->_profiler) {
         $q = $this->_profiler->queryStart('connect', Profiler::CONNECT);
     }
     $config = $this->_config;
     if (!empty($config['driver_options'])) {
         foreach ($config['driver_options'] as $option => $value) {
             parent::options($option, $value);
         }
     }
     //try {省略throw-catch-rethrow块,直接抛出\mysqli_sql_exception
     parent::real_connect((empty($config['persistent']) ? '' : 'p:') . (isset($config['host']) ? $config['host'] : ini_get("mysqli.default_host")), isset($config['username']) ? $config['username'] : ini_get("mysqli.default_user"), isset($config['password']) ? $config['password'] : ini_get("mysqli.default_pw"), isset($config['dbname']) ? $config['dbname'] : "", isset($config['port']) ? $config['port'] : ini_get("mysqli.default_port"), isset($config['socket']) ? $config['socket'] : ini_get("mysqli.default_socket"));
     if ($this->connect_errno) {
         throw new ConnectException($this->connect_error, $this->connect_errno);
     }
     $this->_isConnected = true;
     if ($this->_profiler) {
         $this->_profiler->queryEnd($q);
     }
     if (!empty($config['charset'])) {
         parent::set_charset($config['charset']);
     }
 }
Esempio n. 2
0
 /**
  * Roll back a transaction and return to autocommit mode.
  *
  * @return \Micro\Database\Adapter\AdapterAbstract
  */
 public function rollBack()
 {
     $this->_connect();
     $q = $this->_profiler->queryStart('rollback', \Micro\Database\Profiler::TRANSACTION);
     $this->_rollBack();
     $this->_profiler->queryEnd($q);
     return $this;
 }
Esempio n. 3
0
File: Firebug.php Progetto: hjr3/zf2
 /**
  * Intercept the query end and log the profiling data.
  *
  * @param  integer $queryId
  * @throws \Zend\DB\Profiler\Exception
  * @return void
  */
 public function queryEnd($queryId)
 {
     $state = parent::queryEnd($queryId);
     if (!$this->getEnabled() || $state == self::IGNORED) {
         return;
     }
     $this->_message->setDestroy(false);
     $profile = $this->getQueryProfile($queryId);
     $this->_totalElapsedTime += $profile->getElapsedSecs();
     $this->_message->addRow(array((string) round($profile->getElapsedSecs(), 5), $profile->getQuery(), ($params = $profile->getQueryParams()) ? $params : null));
     $this->updateMessageLabel();
 }