public function __construct($driver, $name, $config)
 {
     parent::__construct($driver, $name, $config);
     $options = $config->get('connectionOptions', array());
     if (!is_array($options)) {
         throw new \PHPixie\Database\Exception("PDO 'connectionOptions' configuration parameter must be an array");
     }
     $this->pdo = $this->connect($config->get('connection'), $config->get('user', ''), $config->get('password', ''), $options);
     $this->pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
     $this->adapterName = strtolower(str_replace('PDO_', '', $this->pdo->getAttribute(\PDO::ATTR_DRIVER_NAME)));
     $this->adapter = $driver->adapter($this->adapterName, $config, $this);
 }
예제 #2
0
 public function __construct($driver, $name, $config)
 {
     parent::__construct($driver, $name, $config);
     $dsn = $config->get('connection');
     if ($dsn !== null) {
         $parts = explode(':', $dsn, 2);
         $adapterName = $parts[0];
     } else {
         $adapterName = $config->getRequired('adapter');
     }
     $this->adapter = $driver->adapter($adapterName, $config, $this);
 }