maske-sanjaya

model

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