create() public static method

Identical to original method except but will return a modified version of MySql driver.
public static create ( $dsn, $user, $password ) : Codeception\Lib\Driver\Db | Codeception\Lib\Driver\MsSql | ExtendedMySql | Codeception\Lib\Driver\Oracle | Codeception\Lib\Driver\PostgreSql | Codeception\Lib\Driver\Sqlite
$dsn
$user
$password
return Codeception\Lib\Driver\Db | Codeception\Lib\Driver\MsSql | ExtendedMySql | Codeception\Lib\Driver\Oracle | Codeception\Lib\Driver\PostgreSql | Codeception\Lib\Driver\Sqlite
Beispiel #1
0
 /**
  * Initializes the module.
  *
  * @return void
  */
 public function _initialize()
 {
     if ($this->config['dump'] && ($this->config['cleanup'] or $this->config['populate'])) {
         if (!file_exists(Configuration::projectDir() . $this->config['dump'])) {
             throw new ModuleConfigException(__CLASS__, "\nFile with dump doesn't exist.\n                    Please, check path for sql file: " . $this->config['dump']);
         }
         $sql = file_get_contents(Configuration::projectDir() . $this->config['dump']);
         $sql = preg_replace('%/\\*(?!!\\d+)(?:(?!\\*/).)*\\*/%s', "", $sql);
         $this->sql = explode("\n", $sql);
     }
     try {
         $this->driver = Driver::create($this->config['dsn'], $this->config['user'], $this->config['password']);
     } catch (\PDOException $e) {
         throw new ModuleConfigException(__CLASS__, $e->getMessage() . ' while creating PDO connection');
     }
     $this->dbh = $this->driver->getDbh();
     // starting with loading dump
     if ($this->config['populate']) {
         $this->cleanup();
         $this->loadDump();
         $this->populated = true;
     }
     $this->tablePrefix = $this->config['tablePrefix'];
 }
Beispiel #2
0
 protected function initialize_driver()
 {
     try {
         $this->driver = Driver::create($this->config['dsn'], $this->config['user'], $this->config['password']);
     } catch (\PDOException $e) {
         throw new ModuleConfigException(__CLASS__, $e->getMessage() . ' while creating PDO connection');
     }
 }