Welcome Guest, Not a member yet? Register   Sign In
Can not use Active Record for simple query?
#1

[eluser]victorche[/eluser]
I need a really simple query with 2 OR and 1 AND like this:
Code:
"SELECT * " .
            "FROM messages " .
            "WHERE (receiver_id = {$user_id} OR " .
                "creator_id = {$user_id} OR " .
                "receiver_id = 0) AND " .
                "deleted = 1"
Trying this with Active Record does not work, since I can not add the brackets. Maybe I am doing it wrong... This is my (not working) code:
Code:
$this->db->from('messages')
                ->where('receiver_id', $user_id)
                ->or_where('creator_id', $user_id)
                ->or_where('receiver_id', 0)
                ->where('deleted', 1)
                ->get();
Can someone tell me how to do it?


Messages In This Thread
Can not use Active Record for simple query? - by El Forum - 03-04-2011, 02:53 AM
Can not use Active Record for simple query? - by El Forum - 03-04-2011, 03:54 AM
Can not use Active Record for simple query? - by El Forum - 03-04-2011, 04:00 AM
Can not use Active Record for simple query? - by El Forum - 03-04-2011, 04:05 AM
Can not use Active Record for simple query? - by El Forum - 03-04-2011, 04:21 AM
Can not use Active Record for simple query? - by El Forum - 03-04-2011, 04:26 AM
Can not use Active Record for simple query? - by El Forum - 03-04-2011, 04:42 AM
Can not use Active Record for simple query? - by El Forum - 03-04-2011, 06:08 AM
Can not use Active Record for simple query? - by El Forum - 03-04-2011, 06:14 AM
Can not use Active Record for simple query? - by El Forum - 03-04-2011, 06:16 AM



Theme © iAndrew 2016 - Forum software by © MyBB