/** * 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']); } }
/** * 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; }