mirror of
https://github.com/dg/dibi.git
synced 2025-08-02 04:10:24 +02:00
examples: dibi:: replaced with $dibi->
This commit is contained in:
@@ -11,7 +11,7 @@ if (@!include __DIR__ . '/../vendor/autoload.php') {
|
||||
date_default_timezone_set('Europe/Prague');
|
||||
|
||||
|
||||
dibi::connect([
|
||||
$dibi = new Dibi\Connection([
|
||||
'driver' => 'sqlite3',
|
||||
'database' => 'data/sample.s3db',
|
||||
]);
|
||||
@@ -25,7 +25,7 @@ $record = [
|
||||
];
|
||||
|
||||
// SELECT ...
|
||||
dibi::select('product_id')->as('id')
|
||||
$dibi->select('product_id')->as('id')
|
||||
->select('title')
|
||||
->from('products')
|
||||
->innerJoin('orders')->using('(product_id)')
|
||||
@@ -37,35 +37,35 @@ dibi::select('product_id')->as('id')
|
||||
|
||||
|
||||
// SELECT ...
|
||||
echo dibi::select('title')->as('id')
|
||||
echo $dibi->select('title')->as('id')
|
||||
->from('products')
|
||||
->fetchSingle();
|
||||
// -> Chair (as result of query: SELECT [title] AS [id] FROM [products])
|
||||
|
||||
|
||||
// INSERT ...
|
||||
dibi::insert('products', $record)
|
||||
$dibi->insert('products', $record)
|
||||
->setFlag('IGNORE')
|
||||
->test();
|
||||
// -> INSERT IGNORE INTO [products] ([title], [price], [active]) VALUES ('Super product', 318, 1)
|
||||
|
||||
|
||||
// UPDATE ...
|
||||
dibi::update('products', $record)
|
||||
$dibi->update('products', $record)
|
||||
->where('product_id = ?', $id)
|
||||
->test();
|
||||
// -> UPDATE [products] SET [title]='Super product', [price]=318, [active]=1 WHERE product_id = 10
|
||||
|
||||
|
||||
// DELETE ...
|
||||
dibi::delete('products')
|
||||
$dibi->delete('products')
|
||||
->where('product_id = ?', $id)
|
||||
->test();
|
||||
// -> DELETE FROM [products] WHERE product_id = 10
|
||||
|
||||
|
||||
// custom commands
|
||||
dibi::command()
|
||||
$dibi->command()
|
||||
->update('products')
|
||||
->where('product_id = ?', $id)
|
||||
->set($record)
|
||||
@@ -73,7 +73,7 @@ dibi::command()
|
||||
// -> UPDATE [products] SET [title]='Super product', [price]=318, [active]=1 WHERE product_id = 10
|
||||
|
||||
|
||||
dibi::command()
|
||||
$dibi->command()
|
||||
->truncate('products')
|
||||
->test();
|
||||
// -> TRUNCATE [products]
|
||||
|
Reference in New Issue
Block a user