Advertisement
hafidh

Model ex1

Jun 18th, 2012
3,519
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.49 KB | None | 0 0
  1. <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  2. class Mmahasiswa extends CI_Model
  3. {
  4.     function __construct()
  5.     {
  6.         parent::__construct();
  7.     }
  8.    
  9.     function insert($insert){
  10.         if($this->db->insert('mahasiswa',$insert)){
  11.             return TRUE;
  12.         }else{
  13.             return FALSE;
  14.         }
  15.     }
  16.     function update($id,$update){
  17.         if($this->db->update('mahasiswa',$update,'id = \''.$id.'\'')){
  18.             return TRUE;
  19.         }else{
  20.             return FALSE;
  21.         }
  22.     }
  23.     function delete($id){
  24.         $delete['id_file'] = $id;
  25.         if($this->db->delete('mahasiswa',$delete)){
  26.             return TRUE;
  27.         }else{
  28.             return FALSE;
  29.         }
  30.     }
  31.     function select($select=NULL,$awal=0,$akhir=10){
  32.         if(! is_null($select))$this->db->like($select);
  33.         $query = $this->db->get('mahasiswa',$akhir,$awal);
  34.         return $query->result();
  35.     }
  36.     function view($select=NULL){
  37.         if(! is_null($select))$this->db->like($select);
  38.         $query = $this->db->get('mahasiswa');
  39.         $arr = $query->result_array();
  40.         if($query->num_rows > 0){
  41.             return $arr[0];
  42.         }else{
  43.             return FALSE;
  44.         }
  45.     }
  46.     function penerima($idu){
  47.         $this->db->where('id <>',$idu);
  48.         $query = $this->db->get('mahasiswa');
  49.         return $query->result();
  50.     }
  51. }
  52. /* End of file mmahasiswa.php */
  53. /* Location: ./application/controllers/welcome.php */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement