示例#1
0
 /**
  * Test getConnectedDsn returns a DSN string if it has been set
  *
  * @covers Zend\Db\Adapter\Driver\Pdo\Connection::getDsn
  */
 public function testGetDsn()
 {
     $dsn = "sqlite::memory:";
     $this->connection->setConnectionParameters(array('dsn' => $dsn));
     try {
         $this->connection->connect();
     } catch (\Exception $e) {
     }
     $responseString = $this->connection->getDsn();
     $this->assertEquals($dsn, $responseString);
 }
 /**
  * @covers Zend\Db\Adapter\Driver\Pdo\Connection::disconnect
  */
 public function testDisconnect()
 {
     $connection = new Connection($this->variables);
     $connection->connect();
     $this->assertTrue($connection->isConnected());
     $connection->disconnect();
     $this->assertFalse($connection->isConnected());
 }
示例#3
0
文件: Pdo.php 项目: Yansor/yafblog
 /**
  * @param string|PDOStatement $sqlOrResource
  * @return Statement
  */
 public function createStatement($sqlOrResource = null)
 {
     $statement = clone $this->statementPrototype;
     if ($sqlOrResource instanceof PDOStatement) {
         $statement->setResource($sqlOrResource);
     } else {
         if (is_string($sqlOrResource)) {
             $statement->setSql($sqlOrResource);
         }
         if (!$this->connection->isConnected()) {
             $this->connection->connect();
         }
         $statement->initialize($this->connection->getResource());
     }
     return $statement;
 }
示例#4
0
 /**
  * Extended to set error mode to silent.
  */
 public function connect()
 {
     parent::connect();
     $this->resource->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_SILENT);
     return $this;
 }