Example #1
0
 /**
  * @covers Zend\Db\Adapter\Driver\Pdo\Pdo::getDatabasePlatformName
  */
 public function testGetDatabasePlatformName()
 {
     // Test platform name for SqlServer
     $this->pdo->getConnection()->setConnectionParameters(array('pdodriver' => 'sqlsrv'));
     $this->assertEquals('SqlServer', $this->pdo->getDatabasePlatformName());
     $this->assertEquals('SQLServer', $this->pdo->getDatabasePlatformName(DriverInterface::NAME_FORMAT_NATURAL));
 }
Example #2
0
 /**
  * {@inheritDoc}
  */
 public function quoteValue($value)
 {
     if ($this->resource instanceof DriverInterface) {
         $this->resource = $this->resource->getConnection()->getResource();
     }
     if ($this->resource) {
         if ($this->resource instanceof PDO) {
             return $this->resource->quote($value);
         }
         if (get_resource_type($this->resource) == 'oci8 connection' || get_resource_type($this->resource) == 'oci8 persistent connection') {
             return "'" . addcslashes(str_replace("'", "''", $value), "\n\r\"") . "'";
         }
     }
     trigger_error('Attempting to quote a value in ' . __CLASS__ . ' without extension/driver support ' . 'can introduce security vulnerabilities in a production environment.');
     return "'" . addcslashes(str_replace("'", "''", $value), "\n\r\"") . "'";
 }
Example #3
0
 /**
  * @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') {
         $this->resource = $driver;
         return $this;
     }
     if ($driver instanceof Pdo\Pdo && $driver->getDatabasePlatformName() == 'Sqlite') {
         $this->resource = $driver->getConnection()->getResource();
         return $this;
     }
     throw new Exception\InvalidArgumentException('$driver must be a Sqlite PDO Zend\\Db\\Adapter\\Driver, Sqlite PDO instance');
 }
Example #4
0
 /**
  * @param \Zend\Db\Adapter\Driver\Pgsql\Pgsql|\Zend\Db\Adapter\Driver\Pdo\Pdo|resource|\PDO $driver
  * @throws \Zend\Db\Adapter\Exception\InvalidArgumentException
  * @return $this
  */
 public function setDriver($driver)
 {
     if ($driver instanceof Pgsql\Pgsql || $driver instanceof Pdo\Pdo && $driver->getDatabasePlatformName() == 'Postgresql') {
         $this->resource = $driver->getConnection()->getResource();
         return $this;
     }
     if (is_resource($driver) && in_array(get_resource_type($driver), array('pgsql link', 'pgsql link persistent')) || $driver instanceof \PDO && $driver->getAttribute(\PDO::ATTR_DRIVER_NAME) == 'pgsql') {
         $this->resource = $driver;
         return $this;
     }
     throw new Exception\InvalidArgumentException('$driver must be a Pgsql or Postgresql PDO Zend\\Db\\Adapter\\Driver, pgsql link resource or Postgresql PDO instance');
 }
Example #5
0
 /**
  * @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');
 }
 /**
  * @covers Zend\Db\Adapter\Driver\Pdo\Connection::prepare
  */
 public function testPrepare()
 {
     $sqlsrv = new Pdo($this->variables);
     $connection = $sqlsrv->getConnection();
     $statement = $connection->prepare('SELECT \'foo\'');
     $this->assertInstanceOf('Zend\\Db\\Adapter\\Driver\\Pdo\\Statement', $statement);
 }