taktikhek

Untitled

Jun 30th, 2019
290
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 News_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('news');
  17. // $sql = "SELECT * FROM news ORDER BY id_news 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_news',$id);
  33. $Q = $this->db->get('news');
  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_news',$id);
  44. $action = $this->db->update('news',$input);
  45. return $action;
  46. }
  47.  
  48. function add($input){
  49. $action = $this->db->insert('news',$input);
  50. return $action;
  51. }
  52.  
  53. function delete($id){
  54. $this->db->where('id_news',$id);
  55. $action = $this->db->delete('news');
  56. return $action;
  57. }
  58. }
  59. ?>
Add Comment
Please, Sign In to add comment