/** * The query class always frees the result so you don't have to worry * about use and store result flags from the prespective of having to * free results * * @return null */ public function testUnBufferedSendQuery() { $driver = $this->conn->getDriver(); $sql = 'SELECT query_id, result FROM test_queries WHERE query_id=1'; $result = $this->query->execute($driver, $sql, MYSQLI_USE_RESULT); $expected = array(array('query_id' => 1, 'result' => 'query issued')); $this->assertEquals($expected, $result); $sql = 'SELECT query_id, result FROM test_queries WHERE query_id=2'; $result = $this->query->execute($driver, $sql); $expected = array(array('query_id' => 2, 'result' => 'query 2 issued')); $this->assertEquals($expected, $result); }
/** * @return null */ public function testMutlipleQueriesSqlErrorFirstQuery() { $sql = 'SELECT query_id, result FROM test_queries WHERE uery_id=3;'; $sql .= 'SELECT query_id, result FROM test_queries WHERE query_id=1;'; $sql .= 'SELECT query_id, result FROM test_queries WHERE query_id=2;'; $options = array(0 => array('result-key' => 'first-query'), 1 => array('result-key' => 'second-query'), 2 => array('result-key' => 'third-query')); $result = $this->query->execute($this->driver, $sql, $this->responseCallback, $options); $this->assertInstanceOf('Appfuel\\Db\\DbResponse', $result); $this->assertTrue($result->isError()); $error = $result->getError(); $this->assertInstanceOf('Appfuel\\Db\\Mysql\\Mysqli\\MultiQuery\\Error', $error); /* indicates the error happened before the result loop */ $this->assertEquals(-1, $error->getIndex()); }
/** * @return null */ public function testMutlipleQueriesSqlErrorFirstQuery() { $sql = 'SELECT query_id, result FROM test_queries WHERE uery_id=3;'; $sql .= 'SELECT query_id, result FROM test_queries WHERE query_id=1;'; $sql .= 'SELECT query_id, result FROM test_queries WHERE query_id=2;'; $options = array(0 => array('result-key' => 'first-query'), 1 => array('result-key' => 'second-query'), 2 => array('result-key' => 'third-query')); $request = new MultiQueryRequest('read'); $request->setSql($sql)->setResultOptions($options); $response = $this->adapter->execute($request); $this->assertInstanceOf($this->responseClass, $response); $this->assertFalse($response->isSuccess()); $this->assertFalse($response->getStatus()); $this->assertTrue($response->isError()); $this->assertEquals(0, $response->getRowCount()); $error = $response->getError(); $this->assertInstanceOf('Appfuel\\Db\\Mysql\\Mysqli\\MultiQuery\\Error', $error); /* indicates the error happened before the result loop */ $this->assertEquals(-1, $error->getIndex()); }