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

Sorting related data

The following is not doing what I had hoped for:

    $this->hasMany("id", "OrderItems", "order_id", ['order' => 'online_reference DESC']);

Can someone please correct me?



98.9k
Accepted
answer

You can use:

$sortedParts = $robot->getParts(['order' => 'online_reference DESC']);

There's no way to define it there where you're expecting