mirror of
https://github.com/dg/dibi.git
synced 2025-07-31 03:10:14 +02:00
examples: dibi:: replaced with $dibi->
This commit is contained in:
@@ -12,23 +12,23 @@ if (@!include __DIR__ . '/../vendor/autoload.php') {
|
||||
}
|
||||
|
||||
|
||||
dibi::connect([
|
||||
$dibi = new Dibi\Connection([
|
||||
'driver' => 'sqlite3',
|
||||
'database' => 'data/sample.s3db',
|
||||
]);
|
||||
|
||||
|
||||
// create new substitution :blog: ==> wp_
|
||||
dibi::getSubstitutes()->blog = 'wp_';
|
||||
$dibi->getSubstitutes()->blog = 'wp_';
|
||||
|
||||
dibi::test('SELECT * FROM [:blog:items]');
|
||||
$dibi->test('SELECT * FROM [:blog:items]');
|
||||
// -> SELECT * FROM [wp_items]
|
||||
|
||||
|
||||
// create new substitution :: (empty) ==> my_
|
||||
dibi::getSubstitutes()->{''} = 'my_';
|
||||
$dibi->getSubstitutes()->{''} = 'my_';
|
||||
|
||||
dibi::test("UPDATE ::table SET [text]='Hello World'");
|
||||
$dibi->test("UPDATE ::table SET [text]='Hello World'");
|
||||
// -> UPDATE my_table SET [text]='Hello World'
|
||||
|
||||
|
||||
@@ -45,13 +45,13 @@ function substFallBack($expr)
|
||||
|
||||
|
||||
// define callback
|
||||
dibi::getSubstitutes()->setCallback('substFallBack');
|
||||
$dibi->getSubstitutes()->setCallback('substFallBack');
|
||||
|
||||
// define substitutes as constants
|
||||
define('SUBST_ACCOUNT', 'eshop_');
|
||||
define('SUBST_ACTIVE', 7);
|
||||
|
||||
dibi::test("
|
||||
$dibi->test("
|
||||
UPDATE :account:user
|
||||
SET name='John Doe', status=:active:
|
||||
WHERE id=", 7
|
||||
|
Reference in New Issue
Block a user