db->insert($table,$data); return $this->db->insert_id(); } // edit function function edit_option($action, $id, $table){ $this->db->where('id',$id); $this->db->update($table,$action); return true; } // edit function function edit_option_md5($action, $id, $table){ $this->db->where('md5(id)', $id); $this->db->update($table,$action); return; } // update function function update($action,$id,$table){ $this->db->where('id',$id); $this->db->update($table,$action); } // update function function update_md5($action,$id,$table){ $this->db->where('md5(id)',$id); $this->db->update($table,$action); } // delete function function delete($id,$table){ if (settings()->type == 'live') { $this->db->delete($table, array('id' => $id)); } return; } // get function function get($table) { $this->db->select(); $this->db->from($table); $this->db->order_by('id','DESC'); $query = $this->db->get(); $query = $query->row(); return $query; } // select by function function get_by_user($table) { $this->db->select(); $this->db->from($table); $this->db->where('business_id', $this->business->uid); $this->db->where('user_id', $this->session->userdata('id')); $this->db->order_by('id','DESC'); $query = $this->db->get(); $query = $query->result(); return $query; } // select by function function select_by_user($table) { $this->db->select(); $this->db->from($table); $this->db->where('user_id', $this->session->userdata('id')); $this->db->order_by('id','ASC'); $query = $this->db->get(); $query = $query->result(); return $query; } // select by function function get_business_by_user($user_id) { $this->db->select(); $this->db->from('business'); $this->db->where('user_id', $user_id); $query = $this->db->get(); $query = $query->result(); return $query; } // select function function select($table) { $this->db->select(); $this->db->from($table); $this->db->order_by('id','DESC'); $query = $this->db->get(); $query = $query->result(); return $query; } // select by business_id function select_by_business_id($table,$business_id) { $this->db->select(); $this->db->from($table); $this->db->where('business_id', $business_id); $this->db->order_by('id','ASC'); $query = $this->db->get(); $query = $query->result(); return $query; } // select by business_id and type function select_by_business_id_and_type($table,$business_id,$type) { $this->db->select(); $this->db->from($table); $this->db->where('business_id', $business_id); $this->db->where('type', $type); $this->db->order_by('id','ASC'); $query = $this->db->get(); $query = $query->result(); return $query; } // asc select function function select_asc($table) { $this->db->select(); $this->db->from($table); $this->db->order_by('id','ASC'); $query = $this->db->get(); $query = $query->result(); return $query; } // select by id function select_option($id,$table) { $this->db->select(); $this->db->from($table); $this->db->where('id', $id); $query = $this->db->get(); $query = $query->result_array(); return $query; } // select by id function get_by_id($id,$table) { $this->db->select(); $this->db->from($table); $this->db->where('id', $id); $query = $this->db->get(); $query = $query->row(); return $query; } // select by id function get_by_md5_id($id,$table) { $this->db->select(); $this->db->from($table); $this->db->where('md5(id)', $id); $query = $this->db->get(); $query = $query->row(); return $query; } // select by id function get_by_md5_data($id,$table) { $this->db->select(); $this->db->from($table); $this->db->where('md5(id)', $id); $query = $this->db->get(); $query = $query->result_array(); return $query; } // get business function get_single_business_by_md5($id) { $this->db->select('b.*, n.name as country_name, n.currency_name, n.currency_symbol, n.currency_code, c.name as category_name'); $this->db->from('business b'); $this->db->where('md5(b.id)', $id); $this->db->join('country n', 'n.id = b.country', 'LEFT'); $this->db->join('business_category c', 'c.id = b.category', 'LEFT'); $this->db->order_by('id', 'ASC'); $query = $this->db->get(); $query = $query->result_array(); return $query; } // get business function get_primary_business() { $this->db->select('b.*'); $this->db->from('business b'); $this->db->where('b.is_primary', 1); $query = $this->db->get(); $query = $query->row(); return $query; } // get business function get_business($uid) { // print_r($this->session->userdata()); if (($this->session->userdata('role') !== null) && $this->session->userdata('role') != 'sadmin') { $this->db->select('b.*, t.name as country'); $this->db->from('business b'); if ($uid != 0) { $this->db->where('b.uid', $uid); }else{ $this->db->where('b.uid', $this->session->userdata('business_id')); } // $this->db->where('b.user_id', $this->session->userdata('id')); $this->db->join('country t', 't.id = b.country', 'LEFT'); $query = $this->db->get(); $query = $query->row(); // print_r($this->db->last_query());//die(); return $query; } return array(); } // get settings function get_settings() { $this->db->select('s.*'); $this->db->from('settings s'); $query = $this->db->get(); $query = $query->row(); return $query; } function getData($table,$id,$business_id) { $this->db->select(); $this->db->from($table); if($business_id != NULL) { $this->db->where('business_id', $business_id); } $this->db->where('id', $id); $query = $this->db->get(); $query = $query->row(); return $query; } }