1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-11 00:24:19 +02:00

renamed some modifiers

This commit is contained in:
David Grudl
2006-06-08 02:02:05 +00:00
parent 3030881f07
commit 1e3728c582
9 changed files with 45 additions and 47 deletions

View File

@@ -35,9 +35,9 @@ if (!dibi::isConnected()) {
if (is_error($state)) {
// $state can be FALSE or Exception
if ($state instanceof Exception)
if ($state instanceof Exception)
echo $state;
else
else
echo 'FALSE';
echo "<br>\n";

View File

@@ -56,7 +56,7 @@ class TDateTime implements IDibiVariable
dibi::connect(array(
'driver' => 'mysqli',
'host' => 'localhost',
'username' => 'root',
'username' => 'root',
'password' => 'xxx', // change to real password!
'charset' => 'utf8',
));

View File

@@ -29,7 +29,7 @@ $arr4 = array(
'a' => 12,
'b' => NULL,
'c%?' => NULL,
'd%T' => time(), // modifier 'T' means datetime
'd%t' => time(), // modifier 'T' means datetime
'e' => 'any string',
);
$arr5 = array('RAND()', '[col1] > [col2]');
@@ -38,14 +38,14 @@ $arr5 = array('RAND()', '[col1] > [col2]');
dibi::test("
SELECT *
FROM [db.table]
WHERE ([test.a] LIKE %D", '1995-03-01', "
OR [b1] IN (", $arr1, ")
WHERE ([test.a] LIKE %d", '1995-03-01', "
OR [b1] IN (", $arr1, ")
OR [b2] IN (%s", $arr1, ")
OR [b3] IN (", $arr2, ")
OR [b4] IN (%n", $arr3, ")
OR [b4] IN (%p", $arr5, ")
AND [c] = 'embedded '' string'
OR [d]=%d", 10.3, "
OR [d]=%i", 10.3, "
OR [true]=", true, "
OR [false]=", false, "
OR [null]=", NULL, "
@@ -53,15 +53,15 @@ LIMIT 10");
// dibi detects INSERT or REPLACE command
dibi::test("INSERT INTO [test]", $arr4);
dibi::test("INSERT INTO [test]", $arr4);
// dibi detects UPDATE command
$n = 123;
dibi::test("UPDATE [test] SET", $arr4, " WHERE [id]=%n", $n);
dibi::test("UPDATE [test] SET", $arr4, " WHERE [id]=%i", $n);
// array with modifier %d - means strings
dibi::test("UPDATE [test] SET%s", $arr4, " WHERE [id]=%n", $n);
dibi::test("UPDATE [test] SET%s", $arr4, " WHERE [id]=%i", $n);
?>

View File

@@ -17,8 +17,8 @@ dibi::connect(array(
));
$cond1 = rand(0,2) < 1;
$cond2 = rand(0,2) < 1;
$cond1 = rand(0,2) < 1;
$cond2 = rand(0,2) < 1;
$user = $cond1 ? 'Davidek' : NULL;
@@ -42,7 +42,7 @@ FROM %if', $cond1, '[one_table] %else [second_table]'
dibi::test('
SELECT *
FROM [test]
WHERE
WHERE
%if', isset($user), '[user]=%s', $user, '
%if', $cond2, 'AND [admin]=1 %end
%else LIMIT 10 %end'