1
0
mirror of https://github.com/dg/dibi.git synced 2025-02-22 18:02:25 +01:00
php-dibi/examples/table-prefix.php

45 lines
724 B
PHP
Raw Normal View History

2008-07-17 03:51:29 +00:00
<h1>dibi prefix & substitute example</h1>
<?php
require_once '../dibi/dibi.php';
dibi::connect(array(
'driver' => 'sqlite',
'database' => 'sample.sdb',
));
// create new substitution :blog: ==> wp_
dibi::addSubst('blog', 'wp_');
// generate and dump SQL
dibi::test("UPDATE [:blog:items] SET [text]='Hello World'");
// create new substitution :: (empty) ==> my_
dibi::addSubst('', 'my_');
// generate and dump SQL
dibi::test("UPDATE [database.::table] SET [text]='Hello World'");
function substFallBack($expr)
{
return 'the_' . $expr;
}
// create substitution fallback
dibi::setSubstFallBack('substFallBack');
// generate and dump SQL
dibi::test("UPDATE [:account:user] SET [name]='John Doe'");