Package DE_EPAGES::Database::API::DBIgalera
Galera specific implementation of DE_EPAGES::Database::API::DBI.
Base |
DE_EPAGES::Database::API::DBImysql |
Functions
lockTables
Since galera does not support the lock tables operation, we try to emulate this with supported functionality. Instead of locking a table, we execute the code inside of an transaction with the isolation level 'repeatable read'. Since 'repeatable read' is the default isolation level we do not need to set it manually.
Syntax |
$dbi->lockTables( $ahTables, $cCode ); |
Example |
$dbi->lockTables( [ { 'table' => 'test', 'mode' => 'WRITE'}, { 'table' => 'test2', 'mode' => 'WRITE'}, ], sub { $dbi->do('DELETE FROM test2 WHERE id = ?', $id); $dbi->do('DELETE FROM test WHERE id = ?', $id); }); |
Input |
|
new
Creates a database connection using the supplied connection parameters.
Syntax |
DE_EPAGES::Database::API::DBIgalera->new( $DataSource, $User, $Password, $CacheKey ); |
Example |
DE_EPAGES::Database::API::DBIgalera->new( 'dbi:galera:storedb', 'root', 'geheim', 'DAL' ); |
Input |
|
Return |
|
transaction
Executes a code block in a transaction.
Syntax |
$dbi->transaction( $cCode, $cRollback ); |
Example |
$dbi->transaction( sub { $dbi->do( "DELETE FROM objects WHERE classid = 25" ); $dbi->do( "DELETE FROM classes WHERE classid = 25" ); } ); |
Input |
|