Bug in where_in() ? |
[eluser]dragon75[/eluser]
Hello, I think I found a bug in where_in(), in deed, when i try to do this : Code: $this->db->where_in('id_product', 'SELECT id_product FROM ((SELECT COUNT(*) AS nb, id_product FROM test GROUP BY id_product) AS r) WHERE r.nb > 3'); I must to do this : Code: $this->db->query('DELETE FROM test WHERE id_product IN (SELECT id_product FROM ((SELECT COUNT(*) AS nb, id_product FROM test GROUP BY id_product) AS r) WHERE r.nb > 3)'); Dragon.
[eluser]pisio[/eluser]
Make : $this->db->last_query(); to see is correct your sql query.
[eluser]dragon75[/eluser]
Yes CI generate this : Code: DELETE FROM `test` WHERE `id_product` IN ('SELECT id_product FROM ((SELECT COUNT(*) AS nb, id_product FROM test GROUP BY id_product) AS r) WHERE r.nb > 3') Instead of this : Code: DELETE FROM `test` WHERE `id_product` IN (SELECT id_product FROM ((SELECT COUNT(*) AS nb, id_product FROM test GROUP BY id_product) AS r) WHERE r.nb > 3)
[eluser]PhilTem[/eluser]
There's no native support for nested queries in CI. There are some libraries that will help you create subqueries, or you can have a look at this link here http://heybigname.com/2009/09/18/using-c...subqueries
[eluser]pisio[/eluser]
[quote author="PhilTem" date="1352662168"]There's no native support for nested queries in CI. There are some libraries that will help you create subqueries, or you can have a look at this link here http://heybigname.com/2009/09/18/using-c...subqueries[/quote] That's very clever.
|
Welcome Guest, Not a member yet? Register Sign In |