Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

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 ?



3.6k
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: http://docs.phalconphp.com/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