Commit 7a71c491 authored by Alexander Butenko's avatar Alexander Butenko

Subquery support in UPDATE/INSERT

parent 8f513b0a
......@@ -579,7 +579,9 @@ class MysqliDb
if ($isUpdate !== false)
$this->_query .= "`" . $column . "` = ";
if (!is_array ($value)) {
if (is_object ($value)) {
$this->_query .= $this->_buildPair ("", $value) . ", ";
} else if (!is_array ($value)) {
$this->_bindParam ($value);
$this->_query .= '?, ';
} else {
......
......@@ -218,11 +218,8 @@ print_r ($products);
### Subqueries
```php
$db->where("id", $db->subQuery()
->where("qty", 2, ">")
->get("products",null,"userId"),
'in');
$ids = $db->subQuery()->where("qty", 2, ">")->get("products", null, "userId");
$db->where("id", $ids, 'in');
$res = $db->get ("users");
// Gives SELECT * FROM users WHERE id IN (SELECT userId FROM products WHERE qty > 2)
```
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment