Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class My_GeneralModel extends CI_Model{
- function insert($table,$data){
- $res = $this->db->insert($table, $data);
- return $res;
- }
- function Update($table, $data, $where){
- $res = $this->db->update($table, $data, $where);
- return $res;
- }
- function delete($table,$data,$where){
- $res = $this->db->update($table, $data,$where);
- return $res;
- }
- function delete_forever($table,$where){
- $res = $this->db->delete($table,$where);
- return $res;
- }
- function check_data($table,$coloumn,$data){
- $query = $this->db->query("SELECT $coloumn FROM $table where $coloumn='".$data."' limit 1");
- $result = $query->result_array();
- return $result;
- }
- function check_data_except_deleted($table,$coloumn,$data){
- $query = $this->db->query("SELECT $coloumn FROM $table where $coloumn='".$data."' and is_deleted='N' limit 1");
- $result = $query->result_array();
- return $result;
- }
- function check_data_update($table,$coloumn,$data,$coloumn_id,$data_id){
- $query = $this->db->query("SELECT $coloumn FROM $table where $coloumn='".$data."' and $coloumn_id!='".$data_id."' limit 1 ");
- $result = $query->result_array();
- return $result;
- }
- function check_data_update_in($table,$coloumn,$data,$coloumn_id,$data_id){
- $query = $this->db->query("SELECT $coloumn FROM $table where $coloumn='".$data."' and $coloumn_id='".$data_id."' limit 1 ");
- $result = $query->result_array();
- return $result;
- }
- function check_last_data($table,$coloumn){
- $query = $this->db->query("SELECT $coloumn FROM $table order by $coloumn desc limit 1");
- $result = $query->result_array();
- return $result;
- }
- public function GetWhereData($table,$data){
- $res=$this->db->get_where($table, $data);
- return $res->row_array();
- }
- public function GetWhereDataOrderBy($table,$data,$coloumn_order,$order){
- $this->db->order_by($coloumn_order,$order);
- $res=$this->db->get_where($table, $data);
- return $res->row_array();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement