Welcome Guest, Not a member yet? Register   Sign In
Active record problem
#1

[eluser]satanrulehis[/eluser]
This is my query used ARecord:
Code:
$this->db->select('jobseeker.user_id,full_name,email,register_date,image,video');
        $this->db->from('jobseeker');
        $this->db->join('user', 'user.user_id = jobseeker.user_id');
        $this->db->limit($num, $offset);
        $this->db->order_by("register_date", "desc");
        $this->db->like('email',$_keyword);        
        $this->db->where('video !=','NULL');
        $this->db->or_where('image !=','NULL');    
        $query = $this->db->get();


---> when it runs:

Code:
SELECT `jobseeker`.`user_id`, `full_name`, `email`, `register_date`, `image`, `video`
FROM (`jobseeker`) JOIN `user` ON `user`.`user_id` = `jobseeker`.`user_id`
WHERE `video` != 'NULL' OR `image` != 'NULL' AND `email` LIKE '%[email protected]%'
ORDER BY `register_date` desc LIMIT 1, 4

---> it's NOT what I want, the exactly SQL is:

Code:
SELECT `jobseeker`.`user_id`, `full_name`, `email`, `register_date`, `image`, `video`
FROM (`jobseeker`) JOIN `user` ON `user`.`user_id` = `jobseeker`.`user_id`
WHERE (`video` != 'NULL' OR `image` != 'NULL') AND `email` LIKE '%[email protected]%'
ORDER BY `register_date` desc LIMIT 1, 4

can you see the ( `video` != 'NULL' OR `image` != 'NULL' ) <-- how to add " ()" ??
Please help me how to do it in Activerecord. Thanks alot
#2

[eluser]mah0001[/eluser]
try this:

Code:
//replace these lines
$this->db->like('email',$_keyword);        
$this->db->where('video !=','NULL');
$this->db->or_where('image !=','NULL');  

//with
$this->db->where("(video!='NULL' or image!='NULL')");//this adds the or with the parenthesis
$this->db->where('email',$_keyword);
#3

[eluser]satanrulehis[/eluser]
Thanks alot, it works perfectly




Theme © iAndrew 2016 - Forum software by © MyBB