Beispiel #1
0
 public function testCreateStatement()
 {
     $driver = new Sqlsrv(array());
     $resource = sqlsrv_connect($this->variables['hostname'], array('UID' => $this->variables['username'], 'PWD' => $this->variables['password']));
     $driver->getConnection()->setResource($resource);
     $stmt = $driver->createStatement('SELECT 1');
     $this->assertInstanceOf('Zend\\Db\\Adapter\\Driver\\Sqlsrv\\Statement', $stmt);
     $stmt = $driver->createStatement($resource);
     $this->assertInstanceOf('Zend\\Db\\Adapter\\Driver\\Sqlsrv\\Statement', $stmt);
     $this->setExpectedException('Zend\\Db\\Adapter\\Exception\\InvalidArgumentException', 'only accepts an SQL string or a Sqlsrv resource');
     $driver->createStatement(new \stdClass());
 }
Beispiel #2
0
 /**
  * Prepare
  *
  * @param  string $sql
  * @return string
  */
 public function prepare($sql)
 {
     if (!$this->isConnected()) {
         $this->connect();
     }
     $statement = $this->driver->createStatement($sql);
     return $statement;
 }
 /**
  * @covers Zend\Db\Adapter\Driver\Sqlsrv\Statement::execute
  */
 public function testExecute()
 {
     $sqlsrv = new Sqlsrv($this->variables);
     $statement = $sqlsrv->createStatement("SELECT 'foo'");
     $this->assertSame($statement, $statement->prepare());
     $result = $statement->execute();
     $this->assertInstanceOf('Zend\\Db\\Adapter\\Driver\\Sqlsrv\\Result', $result);
     unset($resource, $sqlsrvResource);
 }