Advertisement
timonte

admin_model

May 15th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. <?php
  2. defined('BASEPATH') OR exit('No direct script access allowed');
  3.  
  4. class App_Admin extends CI_Model {
  5.  
  6. function __construct()
  7. {
  8. parent::__construct();
  9.  
  10. }
  11.  
  12. function insert($table= '', $data= '')
  13. {
  14. $this->db->insert($table, $data);
  15. }
  16.  
  17. function insert_last($table= '', $data= '')
  18. {
  19. $this->db->insert($table, $data);
  20.  
  21. return $this->db->insert_id();
  22. }
  23.  
  24. function get_all ($table)
  25. {
  26. $this->db->from($table);
  27.  
  28. return $this->db->get();
  29. }
  30.  
  31. function get_where($table = null, $where = null){
  32.  
  33. $this->db->from($table);
  34. $this->db->where($where);
  35.  
  36. return $this->db->get();
  37. }
  38.  
  39. function select_all ($select, $table)
  40. {
  41. $this->db->select($select);
  42. $this->db->from($table);
  43.  
  44. return $this->db->get();
  45. }
  46.  
  47. function select_where ($select, $table, $where)
  48. {
  49. $this->db->select($select);
  50. $this->db->from($table);
  51. $this->db->where($where);
  52.  
  53. return $this->db->get();
  54. }
  55.  
  56. function update($table = null, $data = null, $where = null)
  57. {
  58. $this->db->update($table, $data, $where);
  59. }
  60.  
  61. function delete($table = null, $where = null)
  62. {
  63. $this->db->where($where);
  64. $this->db->delete($table);
  65. }
  66.  
  67. function report($where = '')
  68. {
  69. $this->db->select(array('o.id_order AS id_order', 'fullname', 'kota', 'total', 'SUM(biaya) AS biaya'));
  70. $this->db->from('t_order o JOIN t_detail_order do ON (o.id_order = do.id_order) JOIN t_users u ON (o.id_user = u.id_user)');
  71. $this->db->where($where);
  72. $this->db->group_by('o.id_order');
  73.  
  74. return $this->db->get();
  75. }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement