[CDBI] order_by with joined tables?

Alan <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.class-dbi
Message-ID <[email protected]>
Hey all.  I'm wondering if there's a way to order by a field in a joined
table.  For example, I have:

table company
        id
        name
table people
        id
        fullname
        company_id

package Company;
...
package Person;
...
Person->has_a( company_id => 'Company' );

I can of course get results sorted by any field in the Person class:

@array = Company->search_where( { fullname => 'alan' }, { order_by =>
'fullname' } );

However what I want to do is order by the name of the company in the
join because the order by company_id doesn't work.  

Putting 'company.name' or 'name' in the order_by just bails out.  Using
pure SQL I'd just join the tables together and then order by the company
name with something like:

select name,fullname 
from people join company on company.id = people.company_id
where blah 
order by company.name

However I don't know how to get this into the nice CDBI framework :(

Any pointers appreciated.

TIA

Alan

-- 
Alan <[email protected]> - http://arcterex.net
--------------------------------------------------------------------
"Backups are for people who don't pray."                 -- big Mike
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.