I try to count all my row with date condition in my web, but I don't know why my code still didn't work. I try add (date) in front my column(created_at) but the result:
error "Message: Call to a member function num_rows() on boolean"
This is my code:
public function hitungPerbaikan()
{
$date = new DateTime('now');
$curr_date = $date->format('Y-m-d');
$this->db->where('update_at', $curr_date);
$this->db->where('status >=', '2');
$this->db->from('tbl_kerusakan');
return $this->db->count_all_results();
}
CodePudding user response:
thank for the advice, its really help me to figure it out, this is my code now
public function hitungPerbaikan()
{
$date = new DateTime('now');
$curr_date = $date->format('ymd');
$this->db->where('update_at>=', $curr_date);
$this->db->where('status >=', '2');
$this->db->from('tbl_kerusakan');
$db_result = $this->db->get();
return $db_result->num_rows();
}