Default sort attribute for Doctrine Model
You can specify it in the YAML as follows:
If it's a sorting order for a field in the table itself add:
options: orderBy: fieldname
where options:
is at the same depth as you'd have a columns:
or relations:
entry. NB: The capitalisation of orderBy:
is vital; get it wrong and you'll get no error but also no sorting.
If it's a sorting order for a relationship then, within the relationship you can skip the options:
part and just put in:
orderBy: fieldname
OK, I got around this thanks to this post: http://www.littlehart.net/atthekeyboard/2010/02/04/sorting-relationship-results-in-doctrine-1-2-2/
In my case, the BaseWork.php file had this modifications:
public function setUp() { parent::setUp(); $this->hasMany('Photo as photos', array( 'local' => 'id', 'orderBy' => 'display_order', 'foreign' => 'work_id'));
Anyhow, it would be better to specify this in schema.yml, which I couldn't make work.
I don't know the first thing about doctrine, but it looks like you can specify an order by clause when you call create().