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/blue-sky.co.id/public_html/application/models/ |
Upload File : |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Restaurant_m extends MY_Model { protected $_table_name = 'restaurants'; protected $_primary_key = 'id'; protected $_order_by = 'id'; public $rules = array( array( 'field' => 'name', 'label' => 'Restaurant Name', 'rules' => 'trim|required' ), array( 'field' => 'intro_title', 'label' => 'Intro Title', 'rules' => 'trim' ), array( 'field' => 'intro_content', 'label' => 'Intro Content', 'rules' => 'trim' ), array( 'field' => 'facility_title', 'label' => 'Facility Title', 'rules' => 'trim' ), array( 'field' => 'facility_subtitle', 'label' => 'Facility Subtitle', 'rules' => 'trim' ), array( 'field' => 'testimony_tag', 'label' => 'Testimony Tag', 'rules' => 'trim' ), array( 'field' => 'testimony_title', 'label' => 'Testimony Title', 'rules' => 'trim' ), array( 'field' => 'contact_tag', 'label' => 'Contact Tag', 'rules' => 'trim' ), array( 'field' => 'contact_title', 'label' => 'Contact Title', 'rules' => 'trim' ), array( 'field' => 'contact_subtitle', 'label' => 'Contact Subtitle', 'rules' => 'trim' ), array( 'field' => 'contact_email', 'label' => 'Contact Email', 'rules' => 'trim|valid_email' ), array( 'field' => 'contact_phone', 'label' => 'Contact Phone', 'rules' => 'trim' ), array( 'field' => 'contact_hours', 'label' => 'Contact Hours', 'rules' => 'trim' ), array( 'field' => 'contact_address', 'label' => 'Contact Address', 'rules' => 'trim' ) ); function __construct() { parent::__construct(); } //function add restaurant function add_restaurant($data) { $this->db->insert('restaurants', $data); return $this->db->insert_id(); } //function edit restaurant function edit_restaurant($id, $data) { $this->db->where('id', $id); $this->db->update('restaurants', $data); } //function to get new restaurant object with empty fields function get_new() { $restaurant = new stdClass(); $restaurant->name = ''; $restaurant->banner_image = ''; $restaurant->intro_title = ''; $restaurant->intro_content = ''; $restaurant->intro1_image = ''; $restaurant->intro2_image = ''; $restaurant->intro3_image = ''; $restaurant->facility_title = ''; $restaurant->facility_subtitle = ''; $restaurant->facility1_image = ''; $restaurant->facility1_title = ''; $restaurant->facility1_subtitle = ''; $restaurant->facility2_image = ''; $restaurant->facility2_title = ''; $restaurant->facility2_subtitle = ''; $restaurant->facility3_image = ''; $restaurant->facility3_title = ''; $restaurant->facility3_subtitle = ''; $restaurant->facility4_image = ''; $restaurant->facility4_title = ''; $restaurant->facility4_subtitle = ''; $restaurant->gallery1_image = ''; $restaurant->gallery2_image = ''; $restaurant->gallery3_image = ''; $restaurant->gallery4_image = ''; $restaurant->gallery5_image = ''; $restaurant->gallery6_image = ''; $restaurant->gallery7_image = ''; $restaurant->gallery8_image = ''; $restaurant->gallery9_image = ''; $restaurant->gallery10_image = ''; $restaurant->testimony_tag = ''; $restaurant->testimony_title = ''; $restaurant->testimony1_title = ''; $restaurant->testimony1_name = ''; $restaurant->testimony1_content = ''; $restaurant->testimony1_image = ''; $restaurant->testimony2_title = ''; $restaurant->testimony2_name = ''; $restaurant->testimony2_content = ''; $restaurant->testimony2_image = ''; $restaurant->testimony3_title = ''; $restaurant->testimony3_name = ''; $restaurant->testimony3_content = ''; $restaurant->testimony3_image = ''; $restaurant->testimony4_title = ''; $restaurant->testimony4_name = ''; $restaurant->testimony4_content = ''; $restaurant->testimony4_image = ''; $restaurant->contact_tag = ''; $restaurant->contact_title = ''; $restaurant->contact_subtitle = ''; $restaurant->contact_image = ''; $restaurant->contact_email = ''; $restaurant->contact_hours = ''; $restaurant->contact_phone = ''; $restaurant->contact_address = ''; return $restaurant; } //function count all record for restaurants public function record_count() { return $this->db->select('id')->from('restaurants')->get()->num_rows(); } //pagination included function get_all_restaurants($limit, $start) { $this->db->select('*'); $this->db->from('restaurants'); $this->db->order_by('id', 'ASC'); $this->db->limit($limit, $start); $query = $this->db->get(); return $query->result(); } }