Count of group by in CodeIgniter -


i wan display first 9 places have highest number of reservations. must have count of $this->db->group_by('t.id_pl') , order of counted number.

i've managed don't understand should put count :

function select_pop () {     $this->db->select( 's.place place, s.price price, s.title title' );                 $this->db->from('places s');      $this->db->join('reservations t', 't.id_pl= s.place', 'inner');            $this->db->group_by('t.id_pl');     $this->db->order_by('');      $this->db->limit(9);         $result = $this->db->get();     return $result;  }   

any suggestions?

you can add count in select statement below-

$this->db->select('count(t.id_pl) reservation_count,s.place place, s.price price, s.title title'); 

then order can use like-

$this->db->order_by('reservation_count','desc'); 

i hope you..


Comments

Popular posts from this blog

testing - Detect whether test has failed within fixture -

android - Create single AAR file from multiple modules using Gradle -

AbotX : How do you create a parallel crawler that stays on and can be added to at run time from new requests -