createPdoInstance() protected method

This method is called by [[open]] to establish a DB connection. The default implementation will create a PHP PDO instance. You may override this method if the default PDO needs to be adapted for certain DBMS.
protected createPdoInstance ( ) : PDO
return PDO the pdo instance
コード例 #1
0
 /**
  * Creates the PDO instance.
  * When some functionalities are missing in the pdo driver, we may use
  * an adapter class to provides them.
  * @return \PDO the pdo instance
  */
 protected function createPdoInstance()
 {
     if (!empty($this->charset)) {
         Yii::trace('Error: Oci8PDO_Connection::$charset has been set to `' . $this->charset . '` in your config. The property is only used for MySQL and PostgreSQL databases. If you want to set the charset in Oracle to UTF8, add the following to the end of your Oci8PDO_Connection::$dsn: ;charset=AL32UTF8;', 'vendor\\sfedosimov\\yii2-oci8pdo\\Oci8PDO_Connection');
     }
     try {
         Yii::trace('Opening Oracle connection', 'vendor\\sfedosimov\\yii2-oci8pdo\\Oci8PDO_Connection');
         $pdoClass = parent::createPdoInstance();
     } catch (PDOException $e) {
         throw $e;
     }
     return $pdoClass;
 }