Welcome Guest, Not a member yet? Register   Sign In
some problem with active records
#1

[eluser]Unknown[/eluser]
Hi guys, i have this problem where i want to do a query using where_in and or_where_in it’s not working.
here’s my code:

Code:
function closedprojects(){
    $brandcheck=$this->brandcheck($this->session->userdata(‘member_id’));
    $this->db->from(‘tbl_baf’);
    $this->db->where_in(‘tbl_baf.brands’, $brandcheck);
    $this->db->or_where_in(‘tbl_baf.other_brands’, $brandcheck);
    $this->db->where(‘tbl_baf.status’,‘closed’);
    $this->db->join(‘tbl_expense’, ‘tbl_baf.p_id=tbl_expense.project_id’);
    $this->db->join(‘tbl_brand’, ‘tbl_expense.brand_id=tbl_brand.b_id’,‘left’);
      $query = $this->db->get();
    return $query->result();
  }
this is the mysql version of the CI query
Code:
SELECT * FROM (`tbl_baf`) JOIN `tbl_expense` ON `tbl_baf`.`p_id`=`tbl_expense`.`project_id` LEFT JOIN `tbl_brand` ON `tbl_expense`.`brand_id`=`tbl_brand`.`b_id` WHERE `tbl_baf`.`brands` IN (‘4’, ‘3’, ‘5’, ‘1’, ‘2’)  OR `tbl_baf`.`other_brands` IN (‘4’, ‘3’, ‘5’, ‘1’, ‘2’)  AND `tbl_baf`.`status` = ‘closed’ GROUP BY `tbl_baf`.`p_id`
my problem is ” `tbl_baf`.`status` = ‘closed’” is compulsory but here the case is if the where_in or_where_in get succeed it didn’t checking the status ,can any plz help me to fix this issue
#2

[eluser]toopay[/eluser]
For debug, you can return last query by doing
Code:
return $this->db->last_query();
and echo it on your controller. Then you will have an idea to working on your active record statement.




Theme © iAndrew 2016 - Forum software by © MyBB