1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-03 04:37:35 +02:00

used PHP 5.4 syntax

This commit is contained in:
David Grudl
2015-10-06 01:39:01 +02:00
parent a32e24262f
commit 7c1f735f9b
69 changed files with 718 additions and 733 deletions

View File

@@ -9,10 +9,10 @@ require __DIR__ . '/../src/loader.php';
date_default_timezone_set('Europe/Prague');
dibi::connect(array(
dibi::connect([
'driver' => 'sqlite3',
'database' => 'data/sample.s3db',
));
]);
// SELECT
@@ -30,37 +30,37 @@ dibi::test('
// dibi detects INSERT or REPLACE command
dibi::test('
REPLACE INTO products', array(
REPLACE INTO products', [
'title' => 'Super product',
'price' => 318,
'active' => TRUE,
));
]);
// -> REPLACE INTO products ([title], [price], [active]) VALUES ('Super product', 318, 1)
// multiple INSERT command
$array = array(
$array = [
'title' => 'Super Product',
'price' => 12,
'brand' => NULL,
'created' => new DateTime,
);
];
dibi::test('INSERT INTO products', $array, $array, $array);
// -> INSERT INTO products ([title], [price], [brand], [created]) VALUES ('Super Product', ...) , (...) , (...)
// dibi detects UPDATE command
dibi::test('
UPDATE colors SET', array(
UPDATE colors SET', [
'color' => 'blue',
'order' => 12,
), '
], '
WHERE id=?', 123);
// -> UPDATE colors SET [color]='blue', [order]=12 WHERE id=123
// modifier applied to array
$array = array(1, 2, 3);
$array = [1, 2, 3];
dibi::test('
SELECT *
FROM people
@@ -70,10 +70,10 @@ dibi::test('
// modifier %by for ORDER BY
$order = array(
$order = [
'field1' => 'asc',
'field2' => 'desc',
);
];
dibi::test('
SELECT *
FROM people