Welcome Guest, Not a member yet? Register   Sign In
Bug in where_in() ?
#1

[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');
$this->db->delete('test');

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.
#2

[eluser]pisio[/eluser]
Make :
$this->db->last_query();
to see is correct your sql query.
#3

[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)
#4

[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
#5

[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.
#6

[eluser]dragon75[/eluser]
Tanks Wink




Theme © iAndrew 2016 - Forum software by © MyBB