We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Ask about model class

Hi, how i make this sql "SELECT latitude, longitude, MAX(data) FROM coordenada GROUP BY rota_id" using a model class? i tried find in all docs and i don't found nothing about this!

thank Jhonatas Souza

Hello,

We need to know more about your model to understand your request : what is data and how are store the coordinates ?



5.2k
Accepted
answer

Hi, This code should be works:

$results = Coordenada::find(array(
    'columns' => 'latitude, longitude, MAX(data)'
    'group' => 'rota_id'
));

You can find information about this on models page: https://docs.phalcon.io/en/latest/reference/models.html#finding-records There is a table with list of available parameters which can be used in Model::find.

Thank you all, did not imagine the answer so quickly! = D