I have a current_day_users table and users table.What is the better coding practice between the following to extract data from current_day_users:
1.UsersTable.php code
$this->CurrentDayUsers->find()->where(['user_id'=>$userId,'created'=>$dateToday])->first();
UsersTable.php code
$this->CurrentDayUsers->findUser($userId,$dateToday);
CurrentDayusersTable.php code
public function findUser($userId,$date){
return $this->find()->where(['user_id'=>$userId,'created'=>$date])->first();
}
If you already have CurrentDayUsers table, I'd suggest you to follow the second approach:
This is provides a clean and compact code instead of using the query builder within Users Table.