如何从控制器函数中的结果数组中获取总列字段?
我在
$fields = $query->list_fields()
上使用类似model
的方法,但我怎样才能从controller
获取它。
$result = $this->admin_model->national_certificate_user_search_print($start_date, $end_date);
$total = sizeof($result); // getting total rows
public function national_certificate_user_search_print($start_date, $end_date) {
$tablename = 'national_certificate';
$query = $this->db->select('user_name,gurdiant_name,mother_name,prm_village_name,prm_post_office,prm_thana,prm_district,prsnt_address,prsnt_ward,prsnt_post_office,prsnt_thana,prsnt_district')
->from($tablename)
->where( "uploaded_date BETWEEN '$start_date' AND '$end_date' ", NULL, FALSE )
->get();
$result = $query->result_array();
// var_dump($query->num_fields());
return $result;
}
}
答案 0 :(得分:1)
试试这个,
true
Monday
在这里,您只需要从$result = $this->admin_model->national_certificate_user_search_print($start_date, $end_date);
$total = $result->list_fields(); //this will work now with Object
返回public function national_certificate_user_search_print($start_date, $end_date) {
$tablename = 'national_certificate';
$query = $this->db->select('user_name,gurdiant_name,mother_name,prm_village_name,prm_post_office,prm_thana,prm_district,prsnt_address,prsnt_ward,prsnt_post_office,prsnt_thana,prsnt_district')
->from($tablename)
->where( "uploaded_date BETWEEN '$start_date' AND '$end_date' ", NULL, FALSE )
->get();
return $query;
}
}
对象,然后您就可以在$query
中使用它,以便Model
功能在Controller
中运行。< / p>