1

I have this query to convert into the Active record

SELECT (SELECT image FROM bc_item_image WHERE item_id = i.id LIMIT 1) as item_image, i.description, i.condition,c.cat_name as category_name,i.id as ID FROM bc_item i,bc_category c WHERE i.cat_id = c.id and i.user_id !='$user_id' and i.status = '1' and i.is_bartered = '0' and i.is_cancel = '0' and FIND_IN_SET('$subcat_id',i.interested_cat) order by i.display_count desc
6

2 Answers 2

1

use

$this->db->query('here your SQL query');
0
$this->db->select(" i.description, i.condition,c.cat_name as category_name,i.id,(SELECT image FROM bc_item_image WHERE item_id = i.id LIMIT 1) as item_image");
$this->db->from('bc_item as i');
$this->db->join('bc_category as c', 'i.cat_id = c.id');
      $this->db->where('i.status', 1);
      $this->db->where('i.is_bartered', 0);
      $this->db->where('i.user_id','!=', $user_id);
      $this->db->where('i.is_cancel', 0);
      $this->db->where("FIND_IN_SET('".$subcat_id."','i.interested_cat')");
      $query = $this->db->get();
3
  • it will return null Commented Mar 20, 2018 at 5:39
  • Same thing happen do not retrieve any data .. And i will solve my problem and i m using db->query(). Commented Mar 20, 2018 at 6:02
  • @BhavyaSanchaniya ok
    – Rp9
    Commented Mar 20, 2018 at 6:05

Not the answer you're looking for? Browse other questions tagged or ask your own question.