public function testCreateStatement() { $driver = new IbmDb2(array()); $resource = db2_connect($this->variables['database'], $this->variables['username'], $this->variables['password']); $stmtResource = db2_prepare($resource, 'SELECT 1 FROM SYSIBM.SYSDUMMY1'); $driver->getConnection()->setResource($resource); $stmt = $driver->createStatement('SELECT 1 FROM SYSIBM.SYSDUMMY1'); $this->assertInstanceOf('Zend\\Db\\Adapter\\Driver\\IbmDb2\\Statement', $stmt); $stmt = $driver->createStatement($stmtResource); $this->assertInstanceOf('Zend\\Db\\Adapter\\Driver\\IbmDb2\\Statement', $stmt); $stmt = $driver->createStatement(); $this->assertInstanceOf('Zend\\Db\\Adapter\\Driver\\IbmDb2\\Statement', $stmt); $this->setExpectedException('Zend\\Db\\Adapter\\Exception\\InvalidArgumentException', 'only accepts an SQL string or a ibm_db2 resource'); $driver->createStatement(new \stdClass()); }
/** * @covers Zend\Db\Adapter\Driver\IbmDb2\Statement::execute */ public function testExecute() { $ibmdb2 = new IbmDb2($this->variables); $statement = $ibmdb2->createStatement("SELECT 'foo' FROM SYSIBM.SYSDUMMY1"); $this->assertSame($statement, $statement->prepare()); $result = $statement->execute(); $this->assertInstanceOf('Zend\\Db\\Adapter\\Driver\\IbmDb2\\Result', $result); unset($resource, $ibmdb2); }