Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2014
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. function get_records($table, $where=NULL)
  2. {
  3. if(!empty($where))
  4. {
  5. $this->db->where($where);
  6. }
  7. $query=$this->db->get($table);
  8. if($query->num_rows>0)
  9. {
  10. return $query->result();
  11. }
  12. else
  13. {
  14. return array();
  15. }
  16.  
  17. function get_record($table, $where=NULL)
  18. {
  19. if(!empty($where))
  20. {
  21. $this->db->where($where);
  22. }
  23. $query=$this->db->get($table);
  24. if($query->num_rows>0)
  25. {
  26. return $query->row();
  27. }
  28. else
  29. {
  30. return 0;
  31. }
  32. }
  33.  
  34. function update($table ,$where=NULL ,$data)
  35. {
  36. if(!empty($where))
  37. {
  38. $this->db->where($where);
  39. }
  40. $query=$this->db->update($table,$data);
  41. if($query)
  42. {
  43. return $this->db->affected_rows();
  44. }
  45.  
  46. }
  47.  
  48. function delete($table , $where=NULL)
  49. {
  50. if(!empty($where))
  51. {
  52. $this->db->where($where);
  53. }
  54. if($this->db->delete($table))
  55. {
  56. return $this->db->affected_rows();
  57. }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement