-1

this is my normal mysql command

$query = $this->db->query("SELECT `house_details`.`houses_id` , `house_details`.`house_dis` ,  `house_details`.`house_type` , `house_details`.`area` , `house_details`.`cost` , `house_details`.`user_id` , `image`.`thumb_path`
FROM (
`house_details`
)
LEFT JOIN `image` ON `image`.`house_id` = `house_details`.`houses_id`
AND `house_details`.`status` =1
GROUP BY `houses_id` DESC
LIMIT $start,$limit ");     

return $query->result();

what is the similar code with CI active record class ??

Nick
  • 138,499
  • 22
  • 57
  • 95
Shourob Datta
  • 1,886
  • 22
  • 30

2 Answers2

0

Try this,

$this->db->select('house_details.houses_id, house_details.house_dis, house_details.house_type,house_details.area,house_details.cost,house_details.user_id,image.thumb_path');      
$this->db->from('house_details');
$this->db->join('image', 'image.house_id = house_details.houses_id','left');
$this->db->where('image.status', 1);           
$this->db->order_by("house_details.houses_id DESC");    
$this->db->limit($limit, $start);

$query = $this->db->get();
return $query->result();

Assumed there is no group by since you wanted to order result set in descending order. If group by is there changed it to group_by and remove 'DESC'.

Shaolin
  • 2,541
  • 4
  • 30
  • 41
  • What does it mean? Are you getting an error or you don't you get the expected result? Can you explain more? – Shaolin Sep 29 '12 at 17:22
  • ***soory sir i have a little mistake ... actually my problem is given here*** [http://stackoverflow.com/questions/12659185/mysql-codeigniter-active-record-class) @ Unicorn – Shourob Datta Sep 30 '12 at 06:38
0

Try this:

$this->db->select('...')->
     from('house_details')->
     join('image','image.house_id=house_details.houses_id AND image.status=1','LEFT')->
     where('...')->
     order_by('house_details.houses_id','DESC')->
     limit($start,$limit);
uzsolt
  • 5,832
  • 2
  • 20
  • 32