FebimaHermawan

Model CI

Apr 30th, 2020
455
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.11 KB | None | 0 0
  1. <?php
  2. defined('BASEPATH') OR exit('No direct script access allowed');
  3.  
  4. class Data_penyedia_model extends CI_Model {
  5.  
  6.     // -------------------------------
  7.     // -------------------------------
  8.     //           Construct
  9.     // -------------------------------
  10.     // ---------------------------- //
  11.     public function __construct()
  12.     {
  13.         parent::__construct();
  14.     }
  15.     // -------------------------------
  16.     // ----------- Selesai -----------
  17.     // ---------------------------- //
  18.  
  19.  
  20.     // -------------------------------
  21.     // -------------------------------
  22.     //           Main Model
  23.     // -------------------------------
  24.     // ---------------------------- //
  25.     public function get_data_user_by_id($id_user){
  26.         $this->db->select("*");
  27.         $this->db->from("tb_users");
  28.         $this->db->where("id", $id_user);
  29.         $data = $this->db->get();
  30.         return $data;
  31.     }
  32.     // -------------------------------
  33.     // ----------- Selesai -----------
  34.     // ---------------------------- //
  35.  
  36.    
  37.     // -------------------------------
  38.     // -------------------------------
  39.     //          Table Main
  40.     //        Serverside Model
  41.     // -------------------------------
  42.     // ---------------------------- //
  43.     public function select_vw_users_penyedia($id){
  44.         $this->db->select("*");
  45.         $this->db->from("vw_users_penyedia");
  46.         if ($id != "all") {
  47.             $this->db->where("id", $id);
  48.         }
  49.         $this->db->where("is_deleted", "TIDAK");
  50.         $this->db->order_by("id", "DESC");
  51.         $data   = $this->db->get();
  52.         return $data;
  53.     }
  54.  
  55.     public function select_files($id, $id_penyedia, $kode, $date){
  56.         $this->db->select("*");
  57.         $this->db->from("tb_files");
  58.         if ($id != "all") {
  59.             $this->db->where("id", $id);
  60.         }
  61.         if ($id_penyedia != "all") {
  62.             $this->db->where("id_penyedia", $id_penyedia);
  63.         }
  64.         if ($kode != "all") {
  65.             $this->db->where("kode", $kode);
  66.         }
  67.         if ($date != "all") {
  68.             $this->db->where("date_format(tanggal_buat, '%d-%m-%Y') =", $date);
  69.         }
  70.         $this->db->where("is_deleted", "TIDAK");
  71.         $this->db->order_by("id", "DESC");
  72.         $data   = $this->db->get();
  73.         return $data;
  74.     }
  75.  
  76.     public function select_files_rows($id_penyedia, $kode){
  77.         $this->db->select("*");
  78.         $this->db->from("tb_files");
  79.         if ($id_penyedia != "all") {
  80.             $this->db->where("id_penyedia", $id_penyedia);
  81.         }
  82.         if ($kode != "all") {
  83.             $this->db->where("kode", $kode);
  84.         }
  85.         $this->db->where("is_verified", "YA");
  86.         $this->db->where("is_deleted", "TIDAK");
  87.         $this->db->order_by("id", "DESC");
  88.         $data   = $this->db->get();
  89.         return $data->num_rows();
  90.     }
  91.  
  92.     public function get_data_record_by_date($id_penyedia, $date){
  93.         $this->db->select("*");
  94.         $this->db->from("tb_temporary");
  95.         if ($id_penyedia != 'all') {
  96.             $this->db->where("id_penyedia", $id_penyedia);
  97.         }
  98.         if ($date != 'all') {
  99.             $this->db->where("date_format(tanggal, '%d-%m-%Y') =", $date);
  100.         }
  101.         $this->db->where("status", "data_penyedia");
  102.         $this->db->order_by("id", "DESC");
  103.         $data = $this->db->get();
  104.         return $data;
  105.     }
  106.     // -------------------------------
  107.     // ----------- Selesai -----------
  108.     // ---------------------------- //
  109.  
  110.  
  111.     // -------------------------------
  112.     // -------------------------------
  113.     //        Serverside Model
  114.     // -------------------------------
  115.     // ---------------------------- //
  116.     public function insert_files($data){
  117.         $this->db->insert("tb_files", $data);
  118.         return TRUE;
  119.     }
  120.  
  121.     public function update_files($id, $data){
  122.         $this->db->where("id", $id);
  123.         $this->db->update("tb_files", $data);
  124.         return TRUE;
  125.     }
  126.  
  127.     public function update_data_user($id, $data){  
  128.         $this->db->where("id", $id);
  129.         $this->db->update("tb_users", $data);
  130.         return TRUE;
  131.     }
  132.     // -------------------------------
  133.     // ----------- Selesai -----------
  134.     // ---------------------------- //
  135. }
Advertisement
Add Comment
Please, Sign In to add comment