1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-08 07:06:52 +02:00

- BC change: DibiResult::fetchAll() returns always multidimensional arrays (for single columns use fetchPairs() instead)

- added DibiTable::insertOrUpdate()
- new modifier %by
This commit is contained in:
David Grudl
2008-10-01 16:04:16 +00:00
parent 9b84459f09
commit 9eddba204f
9 changed files with 102 additions and 44 deletions

View File

@@ -31,7 +31,7 @@ class Products extends DibiTable
// create table object
$products = new Products();
$products = new Products;
echo "Table name: $products->name\n";
echo "Primary key: $products->primary\n";
@@ -83,6 +83,13 @@ $id = $products->insert($data);
var_dump($id); // generated id
// inserts or updates row into a table
$data = array();
$data['title'] = 'New product';
$data[$products->primary] = 5;
$products->insertOrUpdate($data);
// is absolutely SQL injection safe
$key = '3 OR 1=1';
$products->delete($key);

View File

@@ -64,3 +64,15 @@ SELECT *
FROM [people]
WHERE [id] IN (", $array, ")
");
// ORDER BY array
$order = array(
'field1' => 'asc',
'field2' => 'desc',
);
dibi::test("
SELECT *
FROM [people]
ORDER BY %by", $order, "
");