initConnection() protected method

This method is invoked right after the DB connection is established. The default implementation turns on PDO::ATTR_EMULATE_PREPARES if [[emulatePrepare]] is true, and sets the database [[charset]] if it is not empty. It then triggers an [[EVENT_AFTER_OPEN]] event.
protected initConnection ( )
示例#1
0
 /**
  * Initializes the DB connection.
  * This method is invoked right after the DB connection is established.
  * The default implementation turns on `PDO::ATTR_EMULATE_PREPARES`
  * if [[emulatePrepare]] is true, and sets the database [[charset]] if it is not empty.
  * It then triggers an [[EVENT_AFTER_OPEN]] event.
  */
 protected function initConnection()
 {
     parent::initConnection();
     if ($this->defaultSchema) {
         $this->pdo->exec('SET CURRENT SCHEMA ' . $this->pdo->quote($this->defaultSchema));
     }
     if ($this->isISeries === null) {
         try {
             $stmt = $this->pdo->query('SELECT * FROM QSYS2.SYSTABLES FETCH FIRST 1 ROW ONLY');
             $this->isISeries = boolval($stmt);
         } catch (\Exception $ex) {
             $this->isISeries = false;
         }
     }
 }