mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-27 21:58:52 +00:00
[ticket/9685] Test for databases that are able to nest transactions
If a database is unable to nest transactions the dbal should implement sql_buffer_nested_transactions to signal that buffering of the outer results and closing of the outer transaction is required to open the inner transaction. PHPBB3-9685
This commit is contained in:
parent
ebe83769e6
commit
f0287f7e57
1 changed files with 24 additions and 0 deletions
|
@ -8,6 +8,7 @@
|
|||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php';
|
||||
|
||||
class phpbb_dbal_select_test extends phpbb_database_test_case
|
||||
{
|
||||
|
@ -317,4 +318,27 @@ class phpbb_dbal_select_test extends phpbb_database_test_case
|
|||
|
||||
$db->sql_freeresult($result);
|
||||
}
|
||||
|
||||
function test_nested_transactions()
|
||||
{
|
||||
$db = $this->new_dbal();
|
||||
|
||||
// nested transactions should work on systems that do not require
|
||||
// buffering of nested transactions, so ignore the ones that need
|
||||
// buffering
|
||||
if ($db->sql_buffer_nested_transactions())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$sql = 'SELECT user_id FROM phpbb_users ORDER BY user_id ASC';
|
||||
$result1 = $db->sql_query($sql);
|
||||
|
||||
$db->sql_transaction('begin');
|
||||
$result2 = $db->sql_query($sql);
|
||||
$row = $db->sql_fetchrow($result2);
|
||||
$db->sql_transaction('commit');
|
||||
|
||||
$this->assertEquals('1', $row['user_id']);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue