note
perrin
Class::DBI doesn't directly handle this situation, partly because it isn't clear how what you are doing should translate into objects. You have a reporting query which brings back a mix of fields from three tables. What class of object should you end up with?<p>
One way to do it is to use Class::DBI::View. That lets you use arbitrary SQL queries and get back a list of objects that correspond to rows, although they are not editable.<p>
Another approach would be to break this down into objects and relationships. If you select a task, you should be able to call <CODE>$task->employee()</CODE> or something similar to get an employee object, and <CODE>$task->status()</CODE> to get a status object. This is more how Class::DBI is intended to be used.<p>
As for the ordering, you can do that in perl, e.g. sort by <CODE>$task->employee()->lname()</CODE>. If you need to do it in the database, you can create multiple constructors in your Task class, using the <CODE>set_sql()</CODE> method to allow them to join other tables. Set up one of these for each possible sort and then call the appropriate one.<p>
There are other approaches, but hopefully that will get you started.
316860
316860