Welcome Guest, Not a member yet? Register   Sign In
MySQL where clause acting up
#1

[eluser]Kola[/eluser]
I have a problem with a query which I can't quite figure out:

Code:
$filter = array('group_id' => 1, 'post_type' => 4);
$filter2 = array('group_id' => 1, 'post_type' => 3);

$this->db->from('posts')->where($filter)->or_where($filter2)->order_by('date', 'desc')->get();

The 'group_id' is dynamic, but in order to find the error I have just hardcoded it in. The issue is that it does not limit it self to the group_id, but all id's across the board. So if I have this in the db:

ID - GROUP_ID - TEXT
------------------------
1 1 Test
2 3 Something
------------------------

It will indeed print both of these out. I am quite sure it's the whole or_where() going crazy, as if I remove that it works, but then I only have 1 post type.

Edit: I am well aware I could do something like array('post_type >=' => 3), but that would take everything above 4 too :/
#2

[eluser]Mauricio de Abreu Antunes[/eluser]
Well,
Lemme understand your problem:
How many results you need?

Check your query.
If you have where and or_where, maybe you are searching for 2 results or more.

Which is your expected query?




Theme © iAndrew 2016 - Forum software by © MyBB