Membatasi Data Yang Ditampilkan Dalam Code igniter




Contoh

 public function get_all_buku()
    {
$this->db->limit(100); //100 Data yang akan muncul
        $query =  $this->db->order_by('id','DESC')->get('tb_Karyawan');
        return $query->result();
    }


$this->db->limit(1);
$query = $this->db->get('my_table');
$myRow = $query->row();



Use This
$this->db->limit(1);

$query = $this->db->get('mytable', 0, 1);
$myRow = $query->row();


https://stackoverflow.com/questions/1630109/select-top-1-equality-for-codeigniter

$data = $this->db->select('*')
                 ->from('order_items,SUM(qty) as total_qty')
                 ->order_by('total_qty','desc')
                 ->limit(5)
                 ->group_by('product_id')
                 ->get()->result_array();


$select = array('products.name as label', 'sum(order_items.qty) as value');
$final = $this -> db -> select($select)
               -> from('products')
               -> join('order_items', 'order_items.product_id = products.id', 'left')
               -> group_by('products.id')
               -> order_by('value', 'DESC')
               -> limit(5)
               -> get() -> result_array();

https://stackoverflow.com/questions/35123111/codeigniter-retrieve-top-5-most-occurring-rows-in-column



Membatasi Data Yang Ditampilkan Dalam Code igniter Membatasi Data Yang Ditampilkan Dalam Code igniter Reviewed by Leo on 09:56 Rating: 5

No comments