/** * 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()); }
/** * @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; }
/** * Extended to set error mode to silent. */ public function connect() { parent::connect(); $this->resource->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_SILENT); return $this; }