Welcome Guest, Not a member yet? Register   Sign In
Help with Active Records
#1

[eluser]Unknown[/eluser]
Hi!

I'm submitting a query that looks something like this:

Code:
$this->db->select('fname,nick,lname,member_class');
$this->db->like('fname', 'do', 'after');
$this->db->or_like('nick', 'do');
$this->db->or_like('lname', 'do','after');
$this->db->where('member_class !=','Class A');
$this->db->get('member');

When I check the SQL that is generate by the code above, I get something like this:

SELECT `fname`, `nick`, `lname`, `member_class` FROM (`member`) WHERE `member_class` != 'Class A' AND `fname` LIKE 'do%' OR `nick` LIKE '%do%' OR `lname` LIKE 'do%'

But with the query above, I keep getting people that have 'do' in their names and a Class A member class, which is not what I want.

Is there a way that I can generate this:

SELECT `fname`, `nick`, `lname`, `member_class` FROM (`member`) WHERE `fname` LIKE 'do%' OR `nick` LIKE '%do%' OR `lname` LIKE 'do%' AND `member_class` != 'Class A'

with active records?

Or better yet, will I be able to generate this with Active Records:

SELECT `fname`, `nick`, `lname`, `member_class` FROM (`member`) WHERE (`member_class` != 'Class A') AND (`fname` LIKE 'do%' OR `nick` LIKE '%do%' OR `lname` LIKE 'do%')





Theme © iAndrew 2016 - Forum software by © MyBB