1
0
mirror of https://github.com/dg/dibi.git synced 2025-02-22 09:53:11 +01:00
php-dibi/examples/fluent.test.php
David Grudl 3728b16a21 - added DibiFluent
- bugfix in dibi::dump()
2008-05-21 11:20:46 +00:00

64 lines
1017 B
PHP

<h1>dibi dump example</h1>
<?php
require_once '../dibi/dibi.php';
dibi::connect(array(
'driver' => 'sqlite',
'database' => 'sample.sdb',
));
$id = 10;
$record = array(
'title' => 'Drtička na trávu',
'price' => 318,
'active' => TRUE,
);
// SELECT ...
dibi::select('product_id')->as('id')
->select('title')
->from('products')
->innerJoin('orders')->using('(product_id)')
->innerJoin('customers USING (customer_id)')
->orderBy('title')
->test();
echo "\n";
// INSERT ...
dibi::insert('products', $record)
->setFlag('IGNORE')
->test();
echo "\n";
// UPDATE ...
dibi::update('products', $record)
->where('product_id = %d', $id)
->test();
echo "\n";
// DELETE ...
dibi::delete('products')
->where('product_id = %d', $id)
->test();
echo "\n";
// custom commands
dibi::command()
->update('products')
->where('product_id = %d', $id)
->set($record)
->test();
echo "\n";
dibi::command()
->truncate('products')
->test();