Advertisement
taktikhek

Untitled

May 30th, 2019
790
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. <?php
  2. /**
  3. *
  4. */
  5. class User_model extends CI_Model
  6. {
  7.  
  8. function __construct()
  9. {
  10. parent::__construct();
  11. }
  12.  
  13. function get_all(){
  14. $data = array();
  15. $this->db->select('*');
  16. $Q = $this->db->get('user');
  17. // $sql = "SELECT * FROM user ORDER BY id_user DESC;";
  18. // $Q = $this->db->query($sql);
  19.  
  20. if ($Q->num_rows()>0) {
  21. foreach ($Q->result_array() as $key => $row) {
  22. $data[]=$row;
  23. }
  24. }
  25. $Q->free_result();
  26. return $data;
  27. }
  28.  
  29. function get_by_id($id){
  30. $data = array();
  31. $this->db->select('*');
  32. $this->db->where('id_user',$id);
  33. $Q = $this->db->get('user');
  34.  
  35. if ($Q->num_rows()>0) {
  36. $data=$Q->row_array();
  37. }
  38. $Q->free_result();
  39. return $data;
  40. }
  41.  
  42. function update($id,$input){
  43. $this->db->where('id_user',$id);
  44. $action = $this->db->update('user',$input);
  45. return $action;
  46. }
  47.  
  48. function add($input){
  49. $action = $this->db->insert('user',$input);
  50. return $action;
  51. }
  52.  
  53. function delete($id){
  54. $this->db->where('id_user',$id);
  55. $action = $this->db->delete('user');
  56. return $action;
  57. }
  58. }
  59. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement