Codeception\Lib\Driver\ExtendedDbDriver::create PHP Method

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
    public static function create($dsn, $user, $password)
    {
        $provider = self::getProvider($dsn);
        switch ($provider) {
            case 'sqlite':
                return new Sqlite($dsn, $user, $password);
            case 'mysql':
                return new ExtendedMySql($dsn, $user, $password);
            case 'pgsql':
                return new PostgreSql($dsn, $user, $password);
            case 'mssql':
                return new MsSql($dsn, $user, $password);
            case 'oracle':
                return new Oracle($dsn, $user, $password);
            case 'sqlsrv':
                return new SqlSrv($dsn, $user, $password);
            case 'oci':
                return new Oci($dsn, $user, $password);
            default:
                return new Db($dsn, $user, $password);
        }
    }

Usage Example

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'];
 }
All Usage Examples Of Codeception\Lib\Driver\ExtendedDbDriver::create
ExtendedDbDriver