mirror of
https://github.com/dg/dibi.git
synced 2025-08-03 20:57:36 +02:00
examples: files renamed
This commit is contained in:
35
examples/using-transactions.php
Normal file
35
examples/using-transactions.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<!DOCTYPE html><link rel="stylesheet" href="data/style.css">
|
||||
|
||||
<h1>Using Transactions | dibi</h1>
|
||||
|
||||
<?php
|
||||
|
||||
require_once 'Nette/Debug.php';
|
||||
require_once '../dibi/dibi.php';
|
||||
|
||||
|
||||
dibi::connect(array(
|
||||
'driver' => 'sqlite',
|
||||
'database' => 'data/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',
|
||||
));
|
||||
|
||||
echo "<h2>After INSERT</h2>\n";
|
||||
dibi::query('SELECT * FROM [products]')->dump();
|
||||
|
||||
|
||||
dibi::rollback(); // or dibi::commit();
|
||||
|
||||
echo "<h2>After rollback</h2>\n";
|
||||
dibi::query('SELECT * FROM [products]')->dump();
|
||||
// -> 3 rows again
|
Reference in New Issue
Block a user