Welcome Guest, Not a member yet? Register   Sign In
DB Active Record Class WHERE question
#1

[eluser]rustyvz[/eluser]
Hello all,

I hope someone can help me with the following:
I have a SQL statement that I need to put into the active record class format:
Code:
SELECT *
FROM qanda
WHERE status = 'public'
AND shortcourse = 'cellbio' AND  (question LIKE '&#xen;docytosis%'
OR  answer LIKE '&#xen;docytosis%')
ORDER BY schoolyear DESC, shortcourse DESC, archivename DESC, createdate ASC, createtime ASC

When I use the following:
Code:
$db->from('qanda');
$db->where('status', $this->parameters['status']);
$db->where('shortcourse', $this->parameters['shortcourse']);
$db->like('question', $this->parameters['keyword']);
$db->orlike('answer', $this->parameters['keyword']);
$db->orderby('schoolyear DESC, shortcourse DESC, archivename DESC, createdate ASC, createtime ASC');

I get this statement as a result:
Code:
SELECT *
FROM qanda
WHERE status = 'public'
AND shortcourse = 'cellbio' AND  question LIKE '&#xen;docytosis%'
OR  answer LIKE '&#xen;docytosis%'
ORDER BY schoolyear DESC, shortcourse DESC, archivename DESC, createdate ASC, createtime ASC

I need those paren around the "AND question LIKE '&#xen;docytosis%' OR answer LIKE '&#xen;docytosis%'" and I need that part of the code to appear with "AND" as it does in the first example.

Any ideas?

Thanks in advance!


Messages In This Thread
DB Active Record Class WHERE question - by El Forum - 12-05-2007, 05:50 PM
DB Active Record Class WHERE question - by El Forum - 12-05-2007, 07:19 PM
DB Active Record Class WHERE question - by El Forum - 12-05-2007, 07:27 PM
DB Active Record Class WHERE question - by El Forum - 12-05-2007, 07:33 PM
DB Active Record Class WHERE question - by El Forum - 12-05-2007, 07:38 PM
DB Active Record Class WHERE question - by El Forum - 12-05-2007, 07:43 PM
DB Active Record Class WHERE question - by El Forum - 12-05-2007, 07:45 PM
DB Active Record Class WHERE question - by El Forum - 12-05-2007, 08:06 PM
DB Active Record Class WHERE question - by El Forum - 12-06-2007, 09:43 AM



Theme © iAndrew 2016 - Forum software by © MyBB