<?php class Cars_model extends CI_Model { public function _consruct(){ parent::_construct(); } function save_carmake($data) { $car_type = $data['car_type']; $this->db->where('car_type', $car_type); $this->db->from('car_make'); $count = $this->db->count_all_results(); if($count > 0) { return "Exist"; } else { $result = $this->db->insert('car_make', $data); if($result) { return "Success"; } else { return "Error"; } } } public function get_carmake_byid($id){ return $this->db->get_where('car_make',array('id'=>$id))->row(); } public function edit_carmake($data,$id){ if($this->db->update('car_make',$data,array('id'=>$id))){ return true; } } public function get_carcolor_byid($id){ return $this->db->get_where('car_color',array('id'=>$id))->row(); } public function edit_carcolor($data,$id){ if($this->db->update('car_color',$data,array('id'=>$id))){ return true; } } public function get_cartype_byid($id){ return $this->db->get_where('car_type',array('id'=>$id))->row(); } public function edit_cartype($data,$id){ if($this->db->update('car_type',$data,array('id'=>$id))){ return true; } } function get_allcars(){ $query = $this->db->where('status',1); $query = $this->db->get('car_make'); $result = $query->result(); return $result; } public function car_delete($id){ $this->db->where('id',$id); // $data = array('status'=>0); $result = $this->db->delete('car_make'); // $this->db->where('id', $id); // $this->db->delete('testimonials'); if($result) { return "success"; } else { return "error"; } } function save_carcolor($data) { $car_color = $data['car_color']; $this->db->where('car_color', $car_color); $this->db->from('car_color'); $count = $this->db->count_all_results(); if($count > 0) { return "Exist"; } else { $result = $this->db->insert('car_color', $data); if($result) { return "Success"; } else { return "Error"; } } } function get_allcarcolor(){ $query = $this->db->where('status',1); $query = $this->db->get('car_color'); $result = $query->result(); return $result; } public function carcolor_delete($id){ $this->db->where('id',$id); // $data = array('status'=>0); $result = $this->db->delete('car_color'); if($result) { return "success"; } else { return "error"; } } function save_cartype($data) { $car_type = $data['type']; $this->db->where('type', $car_type); $this->db->from('car_type'); $count = $this->db->count_all_results(); // $count); // die(); if($count > 0) { return "Exist"; } else { $result = $this->db->insert('car_type', $data); if($result) { return "Success"; } else { return "Error"; } } } function get_allcartype(){ $query = $this->db->where('status',1); $query = $this->db->get('car_type'); $result = $query->result(); return $result; } public function cartype_delete($id){ $this->db->where('id',$id); // $data = array('status'=>0); $result = $this->db->delete('car_type'); if($result) { return "success"; } else { return "error"; } } } ?>