Код контроллера:
public function getSubcategory_post(){
$subcat = array();
$category = $this->input->post('category');
// echo $category;
if($category){
$con['conditions'] = array('category'=>$category);
$subcat = $this->dropdown->getSubcategoryRows($con);
}
echo json_encode($subcat);
}
Код модели:
function getSubcategoryRows($params = array()){
$this->db->select('sub_category.sub_category_id, sub_category.sub_category_name');
// $this->db->from($this->subcatTbl.' as s');
//$this->db->select("*");
$this->db->from("sub_category");
//fetch data by conditions
//fetch data by conditions
if(array_key_exists("conditions",$params)){
foreach ($params['conditions'] as $key => $value) {
if(strpos($key,'.') !== false){
$this->db->where($key,$value);
}else{
$this->db->where('sub_category.'.$key,$value);
}
}
}
$query = $this->db->get();
$result = ($query->num_rows() > 0)?$query->result_array():FALSE;
//return fetched data
return $result;
}