这是我的代码
$attendanceDetail = $this->common->getWhere('tbl_attendance', 'date', $allDate);
$total = $attendanceDetail->num_rows();
if($total >0 )
{
echo "record found";
}
else{
echo "Not Found";
}
如何获取查询结果中的记录总数?
答案 0 :(得分:1)
试试这个: 将此方法放在模型中
public function count_records($table_name) {
return $this->db->count_all($table_name);
}
count_all
是查询构建器类方法,它返回表中记录的总数,参见here
在你的控制器方法中使用它:
$total_records = $this->your_model->count_records('put_table_name_here');
答案 1 :(得分:1)
$attendanceDetail = $this->common->getWhere('tbl_attendance', 'date', $allDate);
$total = count($attendanceDetail);
if($total >0 )
{
echo "record found";
}
else{
echo "Not Found";
}