File: /home/cafsindia/crm_cafsindia_com/application/models/Fund_name_model.php
<?php
class Fund_name_model extends CI_Model{
public function search($search,$rows = 0,$limit_from= 0,$sort='fund_name_id',$order='asc'){
$this->db->from('fund_name');
$this->db->join('amc', 'amc.amc_id = fund_name.amc');
$this->db->where('fund_name.status',1);
$this->db->group_start();
$this->db->like('fund_name_id',$search);
$this->db->or_like('fund_name',$search);
$this->db->or_like('amc.amc_name',$search);
$this->db->group_end();
$this->db->order_by('fund_name_id',$order);
if($rows>0){
$this->db->limit($rows, $limit_from);
}
return $this->db->get();
}
public function get_found_rows($search){
$this->db->from('fund_name');
$this->db->where('status',1);
return $this->db->get()->num_rows();
}
public function get_info($fund_name_id){
$this->db->from('fund_name');
$this->db->where('fund_name_id',$fund_name_id);
$a=$this->db->get();
if($a->num_rows() === 1){
return $a->row();
}else{
foreach ($this->db->list_fields('fund_name') as $field){
$PersonObj->field= '';
}
return $PersonObj;
}
}
public function exists($fund_name_id){
$this->db->from('fund_name');
$this->db->where('fund_name_id', $fund_name_id);
return ($this->db->get()->num_rows() == 1);
}
public function save_fund_name(&$fund_name_data, $fund_name_id = FALSE){
if(!$fund_name_id || !$this->exists($fund_name_id, TRUE)){
$fund_name_data['created_by'] = $this->session->userdata('emp_id');
$fund_name_data['created_date'] = date("Y-m-d h:i:s");
if($this->db->insert('fund_name', $fund_name_data)){
$fund_name_data['fund_name_id'] = $this->db->insert_id();
return TRUE;
}
return FALSE;
}
$fund_name_data['updated_by'] = $this->session->userdata('emp_id');
$fund_name_data['updated_date'] = date("Y-m-d h:i:s");
$this->db->where('fund_name_id', $fund_name_id);
return $this->db->update('fund_name', $fund_name_data);
}
public function get_amc(){
$this->db->from('amc');
$this->db->where('status', 1);
return $this->db->get()->result();
}
public function delete_list($fund_name_id){
$this->db->where_in('fund_name_id',$fund_name_id);
return $this->db->update('fund_name',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('fund_name');
$this->db->where_in('fund_name_id', $cat_ids);
return $this->db->get()->result_array();
}
}
?>