Hello everyone, as you will see I have this query in sql
SELECT MAX(id_alternativa) FROM pregunta_alternativa WHERE id_pregunta = 7
which I'm doing in cakephp using the max function of the framework
public function register() {
$query = $this->PreguntasAlternativas->find()
->select([
'id_alternativa' => $query->func()->max(['id_alternativa'])
])->where(['id_pregunta' => '7']);
$this->set('alternatives',$query);
}
but I get an error this is the message
Error: Call to a member function func () on null File C: \ xampp \ htdocs \ serapp \ src \ Controller \ AlternativesController.php Line: 14
as I see the documentation so its functions are used
I do not know what is wrong doing thanks for your help