mirror of
https://github.com/dg/dibi.git
synced 2025-02-22 09:53:11 +01:00
* DibiConnection::insertId && affectedRows throws exception on failure * added protected throwException() to drivers * DibiPostgreDriver - can build connection string * DibiSqliteDriver - support for parameters 'format:date' & 'format:datetime' * fixed query errors in DibiSqliteDriver * DibiConnection prevents serialization and multiple transactions
28 lines
487 B
PHP
28 lines
487 B
PHP
<h1>dibi transaction example</h1>
|
|
<pre>
|
|
<?php
|
|
|
|
require_once '../dibi/dibi.php';
|
|
|
|
|
|
dibi::connect(array(
|
|
'driver' => 'sqlite',
|
|
'database' => 'sample.sdb',
|
|
));
|
|
|
|
|
|
echo "<h2>Before:</h2>\n";
|
|
dibi::query('SELECT * FROM [products]')->dump();
|
|
|
|
|
|
|
|
dibi::begin();
|
|
dibi::query('INSERT INTO [products]', array(
|
|
'title' => 'Test product',
|
|
));
|
|
dibi::rollback(); // or dibi::commit();
|
|
|
|
|
|
|
|
echo "<h2>After:</h2>\n";
|
|
dibi::query('SELECT * FROM [products]')->dump(); |