Example #1
0
 /**
  * @covers Zend\Db\Adapter\Driver\Sqlsrv\Connection::disconnect
  */
 public function testDisconnect()
 {
     $connection = new Connection($this->variables);
     $connection->connect();
     $this->assertTrue($connection->isConnected());
     $connection->disconnect();
     $this->assertFalse($connection->isConnected());
 }
Example #2
0
 /**
  * @param string $sql
  * @return Statement
  */
 public function createStatement($sqlOrResource = null)
 {
     $statement = clone $this->statementPrototype;
     if (is_string($sqlOrResource)) {
         $statement->setSql($sqlOrResource);
         if (!$this->connection->isConnected()) {
             $this->connection->connect();
         }
         $statement->initialize($this->connection->getResource());
     } elseif (is_resource($sqlOrResource)) {
         $statement->setResource($sqlOrResource);
     }
     return $statement;
 }
Example #3
0
 /**
  * @param string|resource $sqlOrResource
  * @return Statement
  */
 public function createStatement($sqlOrResource = null)
 {
     $statement = clone $this->statementPrototype;
     if (is_string($sqlOrResource)) {
         $statement->setSql($sqlOrResource);
         if (!$this->connection->isConnected()) {
             $this->connection->connect();
         }
         $statement->initialize($this->connection->getResource());
     } elseif (is_resource($sqlOrResource)) {
         $statement->initialize($sqlOrResource);
         // will check the resource type
     } else {
         throw new Exception\InvalidArgumentException('createStatement() only accepts an SQL string or a Sqlsrv resource');
     }
     return $statement;
 }