Esempio n. 1
0
 /**
  * {@inheritDoc}
  */
 public function getAttribute($attribute)
 {
     switch ($attribute) {
         case PDO::ATTR_PERSISTENT:
             return false;
         case PDO::ATTR_PREFETCH:
             return false;
         case PDO::ATTR_CLIENT_VERSION:
             return self::VERSION;
         case PDO::ATTR_SERVER_VERSION:
             return $this->client->getServerVersion();
         case PDO::ATTR_SERVER_INFO:
             return $this->client->getServerInfo();
         case PDO::ATTR_TIMEOUT:
             return $this->attributes['timeout'];
         case PDO::ATTR_HTTP_BASIC_AUTH:
             return $this->attributes['auth'];
         case PDO::ATTR_DEFAULT_FETCH_MODE:
             return $this->attributes['defaultFetchMode'];
         case PDO::ATTR_ERRMODE:
             return $this->attributes['errorMode'];
         case PDO::ATTR_DRIVER_NAME:
             return static::DRIVER_NAME;
         case PDO::ATTR_STATEMENT_CLASS:
             return [$this->attributes['statementClass']];
         default:
             // PHP Switch is a lose comparison
             if ($attribute === PDO::ATTR_AUTOCOMMIT) {
                 return true;
             }
             throw new Exception\PDOException('Unsupported driver attribute');
     }
 }
Esempio n. 2
0
 /**
  * @covers ::getAttribute
  * @covers ::setAttribute
  */
 public function testGetAndSetTimeout()
 {
     $timeout = 3;
     $this->client->expects($this->once())->method('setTimeout')->with($timeout);
     $this->assertEquals(5, $this->pdo->getAttribute(PDO::ATTR_TIMEOUT));
     $this->pdo->setAttribute(PDO::ATTR_TIMEOUT, $timeout);
     $this->assertEquals($timeout, $this->pdo->getAttribute(PDO::ATTR_TIMEOUT));
 }
Esempio n. 3
0
 public function getServerVersion()
 {
     $result = $this->client->getServerVersion();
     $versions = $result->getRows();
     return $versions[0][0];
 }