File: /home/cafsindia/allyindian_com/sbltt/application/models/Veh_category_model.php
<?php
class veh_category_model extends CI_Model
{
public function search($search,$rows = 0,$limit_from= 0,$sort='veh_cat_id',$order='asc'){
$this->db->from('veh_category');
$this->db->where('status',1);
$this->db->group_start();
$this->db->like('veh_cat_id',$search);
$this->db->or_like('veh_category',$search);
$this->db->group_end();
$this->db->order_by('veh_cat_id',$order);
if($rows>0)
{
$this->db->limit($rows, $limit_from);
}
return $this->db->get();
}
public function get_found_rows($search){
$this->db->from('veh_category');
$this->db->where('status',1);
return $this->db->get()->num_rows();
}
public function get_info($veh_cat_id)
{
$this->db->from('veh_category');
$this->db->where('veh_cat_id',$veh_cat_id);
$a=$this->db->get();
if($a->num_rows() === 1)
{
return $a->row();
}
else
{
foreach ($this->db->list_fields('veh_category') as $field)
{
$PersonObj->field= '';
}
return $PersonObj;
}
}
public function exists($veh_cat_id){
$this->db->from('veh_category');
$this->db->where('veh_cat_id', $veh_cat_id);
return ($this->db->get()->num_rows() == 1);
}
/*
Inserts or updates a Category
*/
public function save_category(&$category_data, $veh_cat_id = FALSE){
if(!$veh_cat_id || !$this->exists($veh_cat_id, TRUE))
{
if($this->db->insert('veh_category', $category_data))
{
$category_data['veh_cat_id'] = $this->db->insert_id();
return TRUE;
}
return FALSE;
}
$this->db->where('veh_cat_id', $veh_cat_id);
return $this->db->update('veh_category', $category_data);
}
public function delete_list($veh_cat_id){
$this->db->where_in('veh_cat_id',$veh_cat_id);
return $this->db->update('veh_category',array('status'=>0,'deleted_by'=>$this->session->userdata('emp_id'),'deleted_date'=>date('Y-m-d h:i:s')));
}
public function get_multiple_info($cat_ids){
$this->db->from('veh_category');
$this->db->where_in('veh_cat_id', $cat_ids);
return $this->db->get()->result_array();
}
}
?>