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

Subquery support in UPDATE/INSERT

parent 8f513b0a
...@@ -579,7 +579,9 @@ class MysqliDb ...@@ -579,7 +579,9 @@ class MysqliDb
if ($isUpdate !== false) if ($isUpdate !== false)
$this->_query .= "`" . $column . "` = "; $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->_bindParam ($value);
$this->_query .= '?, '; $this->_query .= '?, ';
} else { } else {
......
...@@ -218,11 +218,8 @@ print_r ($products); ...@@ -218,11 +218,8 @@ print_r ($products);
### Subqueries ### Subqueries
```php ```php
$db->where("id", $db->subQuery() $ids = $db->subQuery()->where("qty", 2, ">")->get("products", null, "userId");
->where("qty", 2, ">") $db->where("id", $ids, 'in');
->get("products",null,"userId"),
'in');
$res = $db->get ("users"); $res = $db->get ("users");
// Gives SELECT * FROM users WHERE id IN (SELECT userId FROM products WHERE qty > 2) // 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