Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php if(! defined('BASEPATH')) exit('No direct script access allowed');
- /**
- * Class Xmall Model
- */
- class Xmall_model extends CI_model
- {
- function __construct() {
- }
- function get_item_master_category($params = null, $count=false)
- {
- $AGENT = 50;
- if ( $count )
- $this->db->select('count(*) as many');
- else
- $this->db->select('a.*');
- $this->db->from('xmall_master_category a');
- // $this->db->join('user_meta b', 'b.user_id=a.id', 'left');
- if(isset($params['category']) && $params['category'] != ''){
- $this->db->like('a.category', $params['category']);
- }
- // if (isset($params['user_type_id'])) {
- // if ($params['user_type_id'] != 'ALL') {
- // $this->db->where('a.user_type_id', $params['user_type_id']);
- // }
- // } else {
- // $this->db->where('a.user_type_id', $AGENT);
- // }
- // $this->db->where('a.idelete', 0);
- $this->db->order_by('a.id');
- if($count == true)
- {
- $result = $this->db->get();
- return $result->row()->many;
- }
- else
- {
- $this->db->limit($params['limit'], $params['offset']);
- $result = $this->db->get();
- return $result->result();
- }
- }
- function get_seq_num_t()
- {
- $this->db->select_max('sort_seq');
- $res = $this->db->get('xmall_master_category')->row();
- return $res;
- }
- public function save_master_category($data, $id = null) {
- if ($id == 'i') {
- $this->db->select("*");
- $this->db->where("category", $data["category"]);
- $res = $this->db->get("xmall_master_category")->result();
- if ( count($res) == 0 ) {
- $save = $this->db->insert('xmall_master_category', $data);
- $i_id = $this->db->insert_id();
- }
- } else {
- $save = $this->db->update('xmall_master_category', $data, array('id' => $id));
- $i_id = $id;
- }
- if ($save) {
- return array(true, $i_id);
- }
- return array(false, null);
- }
- public function update_pic_mall_category($id, $file){
- return $this->db->update('xmall_master_category', array('img' => $file), array('id' => $id));
- }
- public function delete_master_category($id) {
- $this->db->where('id', $id);
- $del = $this->db->delete('xmall_master_category');
- return $del;
- }
- public function get_master_category_data($data) {
- $this->db->select('a.*');
- $this->db->from('xmall_master_category a');
- if(isset($data['id']))
- $this->db->where('a.id', $data['id']);
- if(isset($data['category']))
- $this->db->where('a.category', $data['category']);
- return $this->db->get()->row();
- }
- function get_item_master_agent($params = null, $count=false)
- {
- $AGENT = 50;
- if ( $count )
- $this->db->select('count(*) as many');
- else
- $this->db->select('a.*');
- $this->db->from('xmall_master_agent_delivery a');
- // $this->db->join('user_meta b', 'b.user_id=a.id', 'left');
- if(isset($params['agent']) && $params['agent'] != ''){
- $this->db->like('a.agent', $params['agent']);
- }
- // if (isset($params['user_type_id'])) {
- // if ($params['user_type_id'] != 'ALL') {
- // $this->db->where('a.user_type_id', $params['user_type_id']);
- // }
- // } else {
- // $this->db->where('a.user_type_id', $AGENT);
- // }
- // $this->db->where('a.idelete', 0);
- $this->db->order_by('a.id');
- if($count == true)
- {
- $result = $this->db->get();
- return $result->row()->many;
- }
- else
- {
- $this->db->limit($params['limit'], $params['offset']);
- $result = $this->db->get();
- return $result->result();
- }
- }
- public function get_master_agent_data($data){
- $this->db->select('a.*');
- $this->db->from('xmall_master_agent_delivery a');
- if(isset($data['id']))
- $this->db->where('a.id', $data['id']);
- if(isset($data['agent']))
- $this->db->where('a.agent', $data['agent']);
- return $this->db->get()->row();
- }
- function get_seq_num_agent()
- {
- $this->db->select_max('sort_seq');
- $res = $this->db->get('xmall_master_agent_delivery')->row();
- return $res;
- }
- public function save_master_agent($data, $id = null) {
- if ($id == 'i') {
- $this->db->select("*");
- $this->db->where("agent", $data["agent"]);
- $res = $this->db->get("xmall_master_agent_delivery")->result();
- if ( count($res) == 0 ) {
- $save = $this->db->insert('xmall_master_agent_delivery', $data);
- $i_id = $this->db->insert_id();
- }
- } else {
- $save = $this->db->update('xmall_master_agent_delivery', $data, array('id' => $id));
- $i_id = $id;
- }
- if ($save) {
- return array(true, $i_id);
- }
- return array(false, null);
- }
- public function update_pic_mall_agent($id, $file){
- return $this->db->update('xmall_master_agent_delivery', array('img' => $file), array('id' => $id));
- }
- public function delete_master_agent($id) {
- $this->db->where('id', $id);
- $del = $this->db->delete('xmall_master_category');
- return $del;
- }
- }<?php if(! defined('BASEPATH')) exit('No direct script access allowed');
- /**
- * Class Xmall Model
- */
- class Xmall_model extends CI_model
- {
- function __construct() {
- }
- function get_item_master_category($params = null, $count=false)
- {
- $AGENT = 50;
- if ( $count )
- $this->db->select('count(*) as many');
- else
- $this->db->select('a.*');
- $this->db->from('xmall_master_category a');
- // $this->db->join('user_meta b', 'b.user_id=a.id', 'left');
- if(isset($params['category']) && $params['category'] != ''){
- $this->db->like('a.category', $params['category']);
- }
- // if (isset($params['user_type_id'])) {
- // if ($params['user_type_id'] != 'ALL') {
- // $this->db->where('a.user_type_id', $params['user_type_id']);
- // }
- // } else {
- // $this->db->where('a.user_type_id', $AGENT);
- // }
- // $this->db->where('a.idelete', 0);
- $this->db->order_by('a.id');
- if($count == true)
- {
- $result = $this->db->get();
- return $result->row()->many;
- }
- else
- {
- $this->db->limit($params['limit'], $params['offset']);
- $result = $this->db->get();
- return $result->result();
- }
- }
- function get_seq_num_t()
- {
- $this->db->select_max('sort_seq');
- $res = $this->db->get('xmall_master_category')->row();
- return $res;
- }
- public function save_master_category($data, $id = null) {
- if ($id == 'i') {
- $this->db->select("*");
- $this->db->where("category", $data["category"]);
- $res = $this->db->get("xmall_master_category")->result();
- if ( count($res) == 0 ) {
- $save = $this->db->insert('xmall_master_category', $data);
- $i_id = $this->db->insert_id();
- }
- } else {
- $save = $this->db->update('xmall_master_category', $data, array('id' => $id));
- $i_id = $id;
- }
- if ($save) {
- return array(true, $i_id);
- }
- return array(false, null);
- }
- public function update_pic_mall_category($id, $file){
- return $this->db->update('xmall_master_category', array('img' => $file), array('id' => $id));
- }
- public function delete_master_category($id) {
- $this->db->where('id', $id);
- $del = $this->db->delete('xmall_master_category');
- return $del;
- }
- public function get_master_category_data($data) {
- $this->db->select('a.*');
- $this->db->from('xmall_master_category a');
- if(isset($data['id']))
- $this->db->where('a.id', $data['id']);
- if(isset($data['category']))
- $this->db->where('a.category', $data['category']);
- return $this->db->get()->row();
- }
- function get_item_master_agent($params = null, $count=false)
- {
- $AGENT = 50;
- if ( $count )
- $this->db->select('count(*) as many');
- else
- $this->db->select('a.*');
- $this->db->from('xmall_master_agent_delivery a');
- // $this->db->join('user_meta b', 'b.user_id=a.id', 'left');
- if(isset($params['agent']) && $params['agent'] != ''){
- $this->db->like('a.agent', $params['agent']);
- }
- // if (isset($params['user_type_id'])) {
- // if ($params['user_type_id'] != 'ALL') {
- // $this->db->where('a.user_type_id', $params['user_type_id']);
- // }
- // } else {
- // $this->db->where('a.user_type_id', $AGENT);
- // }
- // $this->db->where('a.idelete', 0);
- $this->db->order_by('a.id');
- if($count == true)
- {
- $result = $this->db->get();
- return $result->row()->many;
- }
- else
- {
- $this->db->limit($params['limit'], $params['offset']);
- $result = $this->db->get();
- return $result->result();
- }
- }
- public function get_master_agent_data($data){
- $this->db->select('a.*');
- $this->db->from('xmall_master_agent_delivery a');
- if(isset($data['id']))
- $this->db->where('a.id', $data['id']);
- if(isset($data['agent']))
- $this->db->where('a.agent', $data['agent']);
- return $this->db->get()->row();
- }
- function get_seq_num_agent()
- {
- $this->db->select_max('sort_seq');
- $res = $this->db->get('xmall_master_agent_delivery')->row();
- return $res;
- }
- public function save_master_agent($data, $id = null) {
- if ($id == 'i') {
- $this->db->select("*");
- $this->db->where("agent", $data["agent"]);
- $res = $this->db->get("xmall_master_agent_delivery")->result();
- if ( count($res) == 0 ) {
- $save = $this->db->insert('xmall_master_agent_delivery', $data);
- $i_id = $this->db->insert_id();
- }
- } else {
- $save = $this->db->update('xmall_master_agent_delivery', $data, array('id' => $id));
- $i_id = $id;
- }
- if ($save) {
- return array(true, $i_id);
- }
- return array(false, null);
- }
- public function update_pic_mall_agent($id, $file){
- return $this->db->update('xmall_master_agent_delivery', array('img' => $file), array('id' => $id));
- }
- public function delete_master_agent($id) {
- $this->db->where('id', $id);
- $del = $this->db->delete('xmall_master_category');
- return $del;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement