/** * @param \Zend\Db\Adapter\Driver\Pdo\Pdo||\PDO $driver * @throws \Zend\Db\Adapter\Exception\InvalidArgumentException * @return $this */ public function setDriver($driver) { if ($driver instanceof \PDO && $driver->getAttribute(\PDO::ATTR_DRIVER_NAME) == 'sqlite' || $driver instanceof Pdo\Pdo && $driver->getDatabasePlatformName() == 'Sqlite') { $this->resource = $driver; return $this; } throw new Exception\InvalidArgumentException('$driver must be a Sqlite PDO Zend\\Db\\Adapter\\Driver, Sqlite PDO instance'); }
/** * @param \Zend\Db\Adapter\Driver\Mysqli\Mysqli|\Zend\Db\Adapter\Driver\Pdo\Pdo||\mysqli|\PDO $driver * @throws \Zend\Db\Adapter\Exception\InvalidArgumentException * @return $this */ public function setDriver($driver) { // handle Zend\Db drivers if ($driver instanceof Mysqli\Mysqli || $driver instanceof Pdo\Pdo && $driver->getDatabasePlatformName() == 'Mysql' || $driver instanceof \mysqli || $driver instanceof \PDO && $driver->getAttribute(\PDO::ATTR_DRIVER_NAME) == 'mysql') { $this->resource = $driver; return $this; } throw new Exception\InvalidArgumentException('$driver must be a Mysqli or Mysql PDO Zend\\Db\\Adapter\\Driver, Mysqli instance or MySQL PDO instance'); }
/** * @param \Zend\Db\Adapter\Driver\Sqlsrv\Sqlsrv|\Zend\Db\Adapter\Driver\Pdo\Pdo||resource|\PDO $driver * @throws \Zend\Db\Adapter\Exception\InvalidArgumentException * @return $this */ public function setDriver($driver) { // handle Zend\Db drivers if ($driver instanceof Pdo\Pdo && in_array($driver->getDatabasePlatformName(), array('SqlServer', 'Dblib')) || $driver instanceof \PDO && in_array($driver->getAttribute(\PDO::ATTR_DRIVER_NAME), array('sqlsrv', 'dblib'))) { $this->resource = $driver; return $this; } throw new Exception\InvalidArgumentException('$driver must be a Sqlsrv PDO Zend\\Db\\Adapter\\Driver or Sqlsrv PDO instance'); }
/** * @param \Zend\Db\Adapter\Driver\Sqlsrv\Sqlsrv|\Zend\Db\Adapter\Driver\Pdo\Pdo||resource|\PDO $driver * @throws \Zend\Db\Adapter\Exception\InvalidArgumentException * @return $this */ public function setDriver($driver) { // handle Zend_Db drivers if ($driver instanceof Pdo\Pdo && $driver->getDatabasePlatformName() == 'Sqlsrv') { /** @var $driver \Zend\Db\Adapter\Driver\DriverInterface */ $this->resource = $driver->getConnection()->getResource(); return $this; } // handle if ($driver instanceof \PDO && $driver->getAttribute(\PDO::ATTR_DRIVER_NAME) == 'sqlsrv') { $this->resource = $driver; return $this; } throw new Exception\InvalidArgumentException('$driver must be a Sqlsrv PDO Zend\\Db\\Adapter\\Driver or Sqlsrv PDO instance'); }