maske-sanjaya

model

Jul 2nd, 2015
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. <?php
  2. class Siswa_model extends CI_Model{
  3. private $primary_key='id';
  4. private $table_name='siswa';
  5.  
  6. function _construct(){
  7. parent::_construct();
  8. }
  9.  
  10.  
  11. function get_paged_list($limit=10,$ofset=0,$order_column='',$order_type='asc')
  12. {
  13. if (empty($order_column) || empty($order_type))
  14. $this->db->order_by($this->primary_key,'asc');
  15. else
  16. $this->db->order_by($order_column,$order_type);
  17. return $this->db->get($this->table_name,$limit,$ofset);
  18. }
  19.  
  20. function count_all(){
  21. return $this->db->count_all($this->table_name);
  22. }
  23.  
  24. function get_by_id($id){
  25. $this->db->where($this->primary_key,$id);
  26. return $this->db->get($this->table_name);
  27. }
  28.  
  29. function save($person){
  30. $this->db->insert($this->table_name,$person);
  31. return $this->db->insert_id();
  32. }
  33.  
  34. function update($id,$person){
  35. $this->db->where($this->primary_key,$id);
  36. $this->db->update($this->table_name,$person);
  37. }
  38.  
  39. function delete($id){
  40. $this->db->where($this->primary_key,$id);
  41. $this->db->delete($this->table_name);
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment