Server : Apache/2.4.18 (Ubuntu) System : Linux canvaswebdesign 3.13.0-71-generic #114-Ubuntu SMP Tue Dec 1 02:34:22 UTC 2015 x86_64 User : oppastar ( 1041) PHP Version : 7.0.33-0ubuntu0.16.04.15 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, Directory : /var/www/mesinpolesshinemate.com/application/models/ |
Upload File : |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Size_m extends MY_Model { protected $_table_name = 'product_size'; protected $_primary_key = 'id_product_size'; protected $_order_by = 'id_product_size'; public $rules = array( array( 'field' => 'size', 'label' => 'size', 'rules' => 'trim|required|callback__cek_existing_size_title' ), ); public $attribute_rules = array( array( 'field' => 'product_attributes', 'label' => 'attributes', 'rules' => 'trim|required|callback__cek_existing_attribute_title' ), ); function __construct() { parent::__construct(); } //pagination included function get_all_product_size($limit, $start) { $this->db->select('*'); $this->db->from('product_size'); $this->db->limit($limit, $start); $query = $this->db->get(); return $query->result(); } function get_all_product_attributes($id) { $this->db->select('*'); $this->db->from('product_attributes'); $this->db->where('id_product_size', $id); $query = $this->db->get(); return $query->result(); } //function to display new product_size, where all fields are empty public function get_new() { $sizes = new stdClass(); $sizes->product_size = ''; $sizes->is_color_option = ''; return $sizes; } //function to display new attributes, where all fields are empty public function get_new_attributes() { $attributes = new stdClass(); $attributes->product_attributes = ''; $attributes->id_product_size = ''; return $attributes; } //get all product_size function get_product_size() { $this->db->select('*'); $this->db->from('product_size'); $query = $this->db->get(); return $query->result(); } //function add new product_size function add_product_size($data) { $this->db->insert('product_size', $data); return $this->db->insert_id(); } //function add new product_attribute function add_product_attributes($data) { $this->db->insert('product_attributes', $data); return $this->db->insert_id(); } //function edit product_attribute function edit_product_attribute($id, $data) { $this->db->where('id_product_attributes', $id); $this->db->update('product_attributes', $data); } //function edit product_size function edit_product_size($id, $data) { $this->db->where('id_product_size', $id); $this->db->update('product_size', $data); } //function count all record for product_size public function record_count() { return $this->db->get('product_size')->num_rows(); } //function count if existing record exist public function count_exist($id) { $this->db->select('*'); $this->db->from('product_size'); $this->db->where('id_product_size', $id); $query = $this->db->get(); return $query->num_rows(); } //FOR FRONT END REGISTRATION PAGE //get all product_size to display at front registration page, with status display 1 only function get_product_size_display_on() { $this->db->select('*'); $this->db->from('product_size'); $this->db->where('status', '1'); $this->db->where('id_product_size !=', '0'); $this->db->order_by('id_product_size asc'); $query = $this->db->get(); return $query->result(); } //cek if size title already exist public function cek_existing_size_title($str, $size_id) { $this->db->select('id_product_size'); $this->db->from('product_size'); $this->db->where('product_size', $str); if ($size_id != NULL) { $this->db->where('id_product_size !=', $size_id); } $query = $this->db->get(); return $query->num_rows(); } //cek if size title already exist public function cek_existing_attribute_title($str, $attribute_id) { $product_option = preg_replace('/\s+/', '', $str); $this->db->select('id_product_attributes'); $this->db->from('product_attributes'); $this->db->where('product_attributes', $str); if ($attribute_id != NULL) { $this->db->where('id_product_attributes !=', $attribute_id); } $query = $this->db->get(); return $query->num_rows(); } }