Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions Tests/Mysqli/MysqliDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,24 @@ public function testGetConnectionCollation()
);
}

#[TestDox('Queries can be run after calling a stored procedure that returns rows')]
public function testQueryAfterCallingStoredProcedure()
{
// Older servers cannot prepare these statements, so run them on the native connection
static::$connection->connect();
$native = static::$connection->getConnection();
$native->query('DROP PROCEDURE IF EXISTS ' . static::$connection->quoteName('jtest_proc'));
$native->query('CREATE PROCEDURE ' . static::$connection->quoteName('jtest_proc') . '() SELECT 1');

try {
$this->assertEquals(1, static::$connection->setQuery('CALL ' . static::$connection->quoteName('jtest_proc') . '()')->loadResult());
$this->assertEquals(1, static::$connection->setQuery('CALL ' . static::$connection->quoteName('jtest_proc') . '()')->loadResult());
$this->assertEquals(2, static::$connection->setQuery('SELECT 2')->loadResult());
} finally {
$native->query('DROP PROCEDURE IF EXISTS ' . static::$connection->quoteName('jtest_proc'));
}
}

#[TestDox('The database connection encryption can be retrieved')]
public function testGetConnectionEncryption()
{
Expand Down
7 changes: 7 additions & 0 deletions src/Mysqli/MysqliStatement.php
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,13 @@ private function bindValues(array $values)
public function closeCursor(): void
{
$this->statement->free_result();

// A CALL of a stored procedure returns further result sets; they must be consumed, or the next statement fails
// with "Commands out of sync"
while ($this->statement->more_results() && $this->statement->next_result()) {
$this->statement->free_result();
}

$this->result = false;
}

Expand Down
Loading