Advertisement
Guest User

Model Associates

a guest
Nov 21st, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.87 KB | None | 0 0
  1. <?php
  2. defined('BASEPATH') OR exit('No direct script access allowed');
  3.  
  4. class Associates_model extends CI_Model {
  5.  
  6. public function __construct() {
  7. $this->load->database();
  8. }
  9.  
  10. // Listing
  11. public function listAssociates() {
  12. $this->db->select('*');
  13. $this->db->from('associates');
  14. $this->db->order_by('id_staff','ASC');
  15. $query = $this->db->get();
  16. return $query->result();
  17. }
  18.  
  19. // Semua
  20. public function semua_associates($limit, $start) {
  21. $this->db->select('*');
  22. $this->db->from('associates');
  23. $this->db->where(array('status_staff'=>'Yes'));
  24. $this->db->limit($limit, $start);
  25. $this->db->order_by('urutan','ASC');
  26. $query = $this->db->get();
  27. return $query->result();
  28. }
  29.  
  30.  
  31. // Semua
  32. public function total_associates() {
  33. $this->db->select('*');
  34. $this->db->from('associates');
  35. $this->db->where(array('status_staff'=>'Ya'));
  36. $this->db->order_by('urutan','ASC');
  37. $query = $this->db->get();
  38. return $query->num_rows();
  39. }
  40.  
  41. // Listing Besar
  42. public function listing_besar() {
  43. $this->db->select('*');
  44. $this->db->from('associates');
  45. $this->db->where(array('status_staff'=>'Ya','ukuran' => 'Besar'));
  46. $this->db->order_by('id_staff','DESC');
  47. $query = $this->db->get();
  48. return $query->result();
  49. }
  50.  
  51. // Besar
  52. public function total_besar() {
  53. $this->db->select('*');
  54. $this->db->from('associates');
  55. $this->db->where(array('status_staff'=>'Ya','ukuran' => 'Besar'));
  56. $this->db->order_by('id_staff','DESC');
  57. $query = $this->db->get();
  58. return $query->num_rows();
  59. }
  60.  
  61. // Detail
  62. public function detail($id_staff) {
  63. $this->db->select('*');
  64. $this->db->from('associates');
  65. $this->db->where('id_staff',$id_staff);
  66. $this->db->order_by('id_staff','DESC');
  67. $query = $this->db->get();
  68. return $query->row();
  69. }
  70.  
  71. // Read Product
  72. public function readAsc($slugAsc) {
  73. $this->db->select('*');
  74. $this->db->from('associates');
  75. $this->db->where('slug_asc',$slugAsc);
  76. $query = $this->db->get();
  77. return $query->row_array();
  78. }
  79.  
  80. // End Product
  81. public function endAsc() {
  82. $this->db->select('*');
  83. $this->db->from('associates');
  84. $this->db->order_by('urutan','DESC');
  85. $query = $this->db->get();
  86. return $query->row_array();
  87. }
  88.  
  89.  
  90. // Tambah
  91. public function tambah($data) {
  92. $this->db->insert('associates',$data);
  93. }
  94.  
  95. // Edit
  96. public function edit($data) {
  97. $this->db->where('id_staff',$data['id_staff']);
  98. $this->db->update('associates',$data);
  99. }
  100.  
  101. // Check delete
  102. public function check($id_staff) {
  103. $query = $this->db->get_where('produk',array('id_staff' => $id_staff));
  104. return $query->num_rows();
  105. }
  106.  
  107. // Delete
  108. public function delete($data) {
  109. $this->db->where('id_staff',$data['id_staff']);
  110. $this->db->delete('associates',$data);
  111. }
  112. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement