Is it possible to set default ordering while finding related records for a particular record by alias (through magic __get)?
<?php
class Robots extends \Phalcon\Mvc\Model
{
public function initialize()
{
$this->hasMany('id', 'RobotsParts', 'robot_id', ['alias' => 'parts']);
}
}
class RobotsParts extends \Phalcon\Mvc\Model
{
public function initialize()
{
$this->belongsTo('robot_id', 'Robots', 'id', ['alias' => 'robot']);
}
}
$robot = Robots::findFirst();
$robot->parts; // unordered RobotsParts here
I can use $robot->getParts(['order'=>'name'])
but it will execute new DB query for every call, while access through property will execute query only ones.