Advertisement
Guest User

My_GeneralModel.php

a guest
Jan 24th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.05 KB | None | 0 0
  1. <?php
  2.  
  3. class My_GeneralModel extends CI_Model{
  4.    
  5.     function insert($table,$data){
  6.         $res = $this->db->insert($table, $data);
  7.         return $res;
  8.     }
  9.  
  10.     function Update($table, $data, $where){
  11.         $res = $this->db->update($table, $data, $where);
  12.         return $res;
  13.     }
  14.  
  15.     function delete($table,$data,$where){
  16.         $res = $this->db->update($table, $data,$where);
  17.         return $res;
  18.     }
  19.  
  20.     function delete_forever($table,$where){
  21.         $res = $this->db->delete($table,$where);
  22.         return $res;
  23.     }
  24.  
  25.     function check_data($table,$coloumn,$data){
  26.         $query = $this->db->query("SELECT $coloumn FROM $table where $coloumn='".$data."' limit 1");
  27.         $result = $query->result_array();
  28.         return $result;
  29.     }  
  30.  
  31.     function check_data_except_deleted($table,$coloumn,$data){
  32.         $query = $this->db->query("SELECT $coloumn FROM $table where $coloumn='".$data."' and is_deleted='N' limit 1");
  33.         $result = $query->result_array();
  34.         return $result;
  35.     }
  36.  
  37.     function check_data_update($table,$coloumn,$data,$coloumn_id,$data_id){
  38.         $query = $this->db->query("SELECT $coloumn FROM $table where $coloumn='".$data."' and  $coloumn_id!='".$data_id."' limit 1 ");
  39.         $result = $query->result_array();
  40.         return $result;
  41.     }
  42.  
  43.     function check_data_update_in($table,$coloumn,$data,$coloumn_id,$data_id){
  44.         $query = $this->db->query("SELECT $coloumn FROM $table where $coloumn='".$data."' and  $coloumn_id='".$data_id."' limit 1 ");
  45.         $result = $query->result_array();
  46.         return $result;
  47.     }
  48.  
  49.     function check_last_data($table,$coloumn){
  50.         $query = $this->db->query("SELECT $coloumn FROM $table order by $coloumn desc limit 1");
  51.         $result = $query->result_array();
  52.         return $result;
  53.     }
  54.  
  55.     public function GetWhereData($table,$data){
  56.         $res=$this->db->get_where($table, $data);
  57.         return $res->row_array();
  58.     }
  59.  
  60.     public function GetWhereDataOrderBy($table,$data,$coloumn_order,$order){
  61.         $this->db->order_by($coloumn_order,$order);
  62.         $res=$this->db->get_where($table, $data);
  63.         return $res->row_array();
  64.     }
  65.  
  66.  
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement