Advertisement
dewa_01

Untitled

Dec 15th, 2019
363
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.54 KB | None | 0 0
  1. <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  2.  
  3. class Model_products extends CI_Model {
  4.  
  5.     public function all(){
  6.         $hasil = $this->db->get('products');
  7.         if($hasil->num_rows() > 0){
  8.             return $hasil->result();
  9.         } else {
  10.             return array();
  11.         }
  12.     }
  13.    
  14.     public function find($id){
  15.         //Query mencari record berdasarkan ID-nya
  16.         $hasil = $this->db->where('id', $id)
  17.                           ->limit(1)
  18.                           ->get('products');
  19.         if($hasil->num_rows() > 0){
  20.             return $hasil->row();
  21.         } else {
  22.             return array();
  23.         }
  24.     }  
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement