[eluser]Bigil Michael[/eluser]
code i used to calculate the count is given below
Code:
$count=0;
$this->db->select('COUNT(rr.id) AS total');
$this->db->from('rooms_reservation AS rr');
$this->db->join('rooms AS r', 'r.id = rr.rooms_id');
$this->db->where('rr.status','1');
$this->db->group_by(array("rr.category_id", "rr.checkin_date", "rr.checkout_date", "rr.reservation_date", "rr.name", "rr.email", "rr.num_rooms"));
$result_total = $this->db->get();
if($result_total->num_rows()>0){
$row = $result_total->row();
$count = $row->total;
}
return $count;
every time it prints count 1.
i print the query and run on mysql
Code:
SELECT COUNT(rr.id) AS total FROM (`rooms_reservation` AS rr) JOIN `rooms` AS r ON `r`.`id` = `rr`.`rooms_id` WHERE `rr`.`status` = '1' GROUP BY `rr`.`category_id`, `rr`.`checkin_date`, `rr`.`checkout_date`, `rr`.`reservation_date`, `rr`.`name`, `rr`.`email`, `rr`.`num_rooms`
result is like this
total
1
1
2
2
2
2
.
.
.
like this
if i remove group by count prints correctly. but cant remove group by.
can any one help me to solve this problem