Example #1
0
 /**
  * Creates a PDO object and connects to the database.
  *
  * @return void
  * @throws \Micro\Database\Adapter\Exception
  */
 protected function _connect()
 {
     if ($this->_connection) {
         return;
     }
     parent::_connect();
     if (!empty($this->_config['charset'])) {
         $sql = "SET NAMES '" . $this->_config['charset'] . "'";
         $this->_connection->exec($sql);
     }
 }
Example #2
0
 /**
  * Creates a PDO object and connects to the database.
  *
  * @return void
  * @throws \Micro\Database\Adapter\Exception
  */
 protected function _connect()
 {
     if ($this->_connection) {
         return;
     }
     if (!empty($this->_config['charset'])) {
         $initCommand = "SET NAMES '" . $this->_config['charset'] . "'";
         $this->_config['driver_options'][1002] = $initCommand;
         // 1002 = PDO::MYSQL_ATTR_INIT_COMMAND
     }
     parent::_connect();
 }