Esempio n. 1
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');
 }
Esempio n. 2
0
 /**
  * @depends testRegisterConnection
  * @covers Zend\Db\Adapter\Driver\Pgsql\Pgsql::getConnection
  */
 public function testGetConnection($mockConnection)
 {
     $conn = new \Zend\Db\Adapter\Driver\Pgsql\Connection(array());
     $this->pgsql->registerConnection($conn);
     $this->assertSame($conn, $this->pgsql->getConnection());
 }