mirror of
https://github.com/dg/dibi.git
synced 2025-08-08 23:26:49 +02:00
prefix & substitution support (0.6c)
This commit is contained in:
@@ -30,21 +30,8 @@ dibi::connect(array(
|
||||
if (!dibi::isConnected()) {
|
||||
echo 'dibi::isConnected(): Not connected';
|
||||
echo "<br>\n";
|
||||
} else {
|
||||
echo 'Connected';
|
||||
}
|
||||
|
||||
|
||||
// or checked status this way
|
||||
if (is_error($state)) {
|
||||
|
||||
// $state can be FALSE or Exception
|
||||
if ($state instanceof Exception)
|
||||
echo $state;
|
||||
else
|
||||
echo 'FALSE';
|
||||
|
||||
echo "<br>\n";
|
||||
}
|
||||
|
||||
|
||||
|
||||
?>
|
32
examples/table-prefix.php
Normal file
32
examples/table-prefix.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
require_once '../dibi/dibi.php';
|
||||
|
||||
|
||||
// connects to mysqli
|
||||
dibi::connect(array(
|
||||
'driver' => 'mysqli',
|
||||
'host' => 'localhost',
|
||||
'username' => 'root',
|
||||
'password' => 'xxx', // change to real password!
|
||||
'charset' => 'utf8',
|
||||
));
|
||||
|
||||
|
||||
// create new substitution :blog: ==> wp_items_
|
||||
dibi::addSubst('blog', 'wp_items_');
|
||||
|
||||
|
||||
// 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'");
|
||||
|
||||
|
||||
?>
|
Reference in New Issue
Block a user