tags:

views:

23

answers:

1

Hi, I am using containable to reduce the size of my finds but I have got stuck when trying to order the find data, the find can't seem to see the institution join.

Here is my code -

$result = $this->Candidate->find('all', array(
    'conditions' => array('Candidate.id' => $candidatesCodes),
    'contain' => array(
        'History' => array(
            'Institution' => array('fields' => array('Institution.name'))
            )
        ),
        'order' => array('Institution.name, Candidate.lastname')
    ));

I get this error -

 SQL Error: 1054: Unknown column 'Institution.name' in 'order clause' [CORE/cake/libs/model/datasources/dbo_source.php, line 525]

Thanks, Alex

+2  A: 

Containable generates several queries. Your ordering would work if that would be the single query. You can achieve that by using 'joins'.

bancer