I have two models: Event
and Match
. An event can have many matches. My Match
model has $order = array('match_order' => 'asc')
. The match_order
column in my matches
database table is just a simple INT
column to order matches.
I have a controller method that updates the order of matches. However, because I fetch matches through the event, they don't seem to come in ascending by match_order
, but by the id
column. Here is an example call:
<?php
class EventsController extends AppController {
public function view($id) {
$event = $this->Event->find('first', array(
'conditions' => array(
'Event.id' => $id
),
'contain' => array('Match')
));
}
}
All the related matches come back as expected, but just not in the right order. I've cleared my model caches, is there anything else I need to do to get the matches order by the value in the Match
model?