1
0
mirror of https://github.com/dg/dibi.git synced 2025-02-24 02:43:09 +01:00
php-dibi/examples/transaction.php
David Grudl 8d063fe0a1 - added DibiPostgreDriver::getIndexes()
- implemented DibiTables types autodetection
- all examples uses Nette::Debug
2008-10-28 19:31:32 +00:00

31 lines
509 B
PHP

<h1>dibi transaction example</h1>
<pre>
<?php
require_once 'Nette/Debug.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();
// -> 3 rows
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();
// -> 3 rows