Advertisement
Guest User

Unit_m.php

a guest
Apr 1st, 2020
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.87 KB | None | 0 0
  1. <?php defined('BASEPATH') OR exit('No direct script access allowed');
  2.  
  3. class unit_m extends CI_Model {
  4.  
  5.     public function get($id = null) {
  6.         $this->db->from('p_unit');
  7.         if($id != null) {
  8.             $this->db->where('unit_id', $id);
  9.         }
  10.         $query = $this->db->get();
  11.         return $query;
  12.     }
  13.  
  14.     public function add($post) {
  15.         $params = [
  16.             'name' => $post['unit_name']
  17.         ];
  18.         $this->db->insert('p_unit', $params);
  19.     }
  20.  
  21.     public function edit($post) {
  22.         $params = [
  23.             'name' => $post['unit_name'],
  24.             'updated' => date('Y-m-d H:i:s')
  25.         ];
  26.         $this->db->where('unit_id', $post['id']);
  27.         $this->db->update('p_unit', $params);
  28.     }
  29.  
  30.     public function del($id){
  31.         $this->db->where('unit_id', $id);
  32.         $this->db->delete('p_unit');
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement