Advertisement
Guest User

dddd

a guest
Aug 20th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  2. class Mdl_tasks extends CI_Model
  3. {
  4.  
  5. function __construct() {
  6. parent::__construct();
  7. }
  8.  
  9. function get_table()
  10. {
  11. $table = "task";
  12. return $table;
  13. }
  14.  
  15. function get($order_by)
  16. {
  17. $table = $this->get_table();
  18. $this->db->order_by($order_by);
  19. $query=$this->db->get($table);
  20. return $query;
  21. }
  22.  
  23. function get_with_limit($limit, $offset, $order_by)
  24. {
  25. $table = $this->get_table();
  26. $this->db->limit($limit, $offset);
  27. $this->db->order_by($order_by);
  28. $query=$this->db->get($table);
  29. return $query;
  30. }
  31.  
  32. function get_where_custom($col, $value)
  33. {
  34. $table = $this->get_table();
  35. $this->db->where($col, $value);
  36. $query=$this->db->get($table);
  37. return $query;
  38. }
  39.  
  40. function _insert($data)
  41. {
  42. $table = $this->get_table();
  43. $this->db->insert($table, $data);
  44. }
  45.  
  46. function _update($id, $data)
  47. {
  48. $table = $this->get_table();
  49. $this->db->where('id', $id);
  50. $this->db->update($table, $data);
  51. }
  52.  
  53. function _delete($id)
  54. {
  55. $table = $this->get_table();
  56. $this->db->where('id', $id);
  57. $this->db->delete($table);
  58. }
  59.  
  60. function count_where($column, $value)
  61. {
  62. $table = $this->get_table();
  63. $this->db->where($column, $value);
  64. $query=$this->db->get($table);
  65. $num_rows = $query->num_rows();
  66. return $num_rows;
  67. }
  68.  
  69. function count_all()
  70. {
  71. $table = $this->get_table();
  72. $query=$this->db->get($table);
  73. $num_rows = $query->num_rows();
  74. return $num_rows;
  75. }
  76.  
  77. function get_max()
  78. {
  79. $table = $this->get_table();
  80. $this->db->select_max('id');
  81. $query = $this->db->get($table);
  82. $row=$query->row();
  83. $id=$row->id;
  84. return $id;
  85. }
  86.  
  87. function _custom_query($mysql_query)
  88. {
  89. $query = $this->db->query($mysql_query);
  90. return $query;
  91. }
  92.  
  93. function get_where($id)
  94. {
  95. $table = $this->get_table();
  96. $this->db->where('id', $id);
  97. $query = $this->db->get($table);
  98. return $query;
  99. }
  100.  
  101. }//end of class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement