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:
@@ -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);
|
||||
|
@@ -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, "
|
||||
");
|
||||
|
Reference in New Issue
Block a user