Commit be045c2c authored by Sergei Morozov's avatar Sergei Morozov Committed by Marco Pivetta

[DBAL-2546] Ported tests from #2487 and #2489

parent d0681ed8
......@@ -132,4 +132,45 @@ EOF
);
$this->assertSame($contents, stream_get_contents($stream));
}
public function testIncompletelyFetchedStatementDoesNotBlockConnection()
{
$table = new Table('stmt_test_non_fetched');
$table->addColumn('id', 'integer');
$this->_conn->getSchemaManager()->createTable($table);
$this->_conn->insert('stmt_test_non_fetched', array('id' => 1));
$this->_conn->insert('stmt_test_non_fetched', array('id' => 2));
$stmt1 = $this->_conn->prepare('SELECT id FROM stmt_test_non_fetched');
$stmt1->execute();
$stmt1->fetch();
$stmt1->execute();
// fetching only one record out of two
$stmt1->fetch();
$stmt2 = $this->_conn->prepare('SELECT id FROM stmt_test_non_fetched WHERE id = ?');
$stmt2->execute(array(1));
$this->assertEquals(1, $stmt2->fetchColumn());
}
public function testReuseStatementAfterClosingCursor()
{
$table = new Table('stmt_test_close_cursor');
$table->addColumn('id', 'integer');
$this->_conn->getSchemaManager()->createTable($table);
$this->_conn->insert('stmt_test_close_cursor', array('id' => 1));
$this->_conn->insert('stmt_test_close_cursor', array('id' => 2));
$stmt = $this->_conn->prepare('SELECT id FROM stmt_test_close_cursor WHERE id = ?');
$stmt->execute(array(1));
$id = $stmt->fetchColumn();
$this->assertEquals(1, $id);
$stmt->closeCursor();
$stmt->execute(array(2));
$id = $stmt->fetchColumn();
$this->assertEquals(2, $id);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment