[Dbix-class] Multi Join

Will Smith willbelair at yahoo.com
Mon Aug 27 15:03:19 GMT 2007


Hi,
 I am trying to do a multi join with some params. My code is:
 
 my $rs = [$c->model('myappDB::City')->search(
     {
       'calls.CallerID' => '1',
       'calls.CallStatusID' => '0'
     },
     {       
       join => { 'property' => 'calls' },
       order_by => 'me.CityName'
     } 
     )];
 -----------------------------------------
 
 in my DB.pm files:
 
 property:
 __PACKAGE__->has_many(calls => 'myappDB::Call', 'PropertyID');
 __PACKAGE__->belongs_to(city => 'myappDB::City', 'CityID');
 
 city:
 __PACKAGE__->has_many(property => 'myappDB::Property', 'CityID');
 
 calls:
 __PACKAGE__->belongs_to(property => 'accessDB::Property', 'PropertyID');
 
 -------------------------
 and this is my outcome: (column names) City,PropertyName,CallNumberID
 
   Altoona,Courtyard by Marriott Altoona,
   Atlanta,,
   Columbus,,
   Greeneville,Main Stay Greenville,
   Mississauga,,
   Pittsburgh,,
   White Plains,Residence Inn White Plains,
 
 ---------------------
 
 This is my template:
 [% FOREACH rs IN rs %]
 [% rs.CityName %],[% rs.property.PropertyName %],[% rs.property.calls.CallNumberID %]<br>
 [% END %]
 
 --------------
 
 As you can see, I have missing data. Is there something wrong that I did?
 This is mydate from mysql query:
 +--------------+----------------------------------------+--------------+
 | CityName     | PropertyName                           | CallNumberID |
 +--------------+----------------------------------------+--------------+
 | Altoona      | Courtyard by Marriott Altoona          |          964 |
 | Atlanta      | Residence Inn Atlanta                  |          764 |
 | Columbus     | Courtyard by Marriott Columbus Airport |          904 |
 | Greeneville  | Main Stay Greenville                   |         1064 |
 | Mississauga  | Courtyard Mississauga-Airport          |          704 |
 | Pittsburgh   | MainStay Pittsburgh                    |         1004 |
 | White Plains | Residence Inn White Plains             |          864 |
 +--------------+----------------------------------------+--------------+
 
 I also, try different join by selecting the main table is calls, or property, and still getting stuck on the sorting
 
 
 Thank you,
 Will
 
 
       
---------------------------------
Luggage? GPS? Comic books? 
Check out fitting  gifts for grads at Yahoo! Search.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20070827/80883856/attachment.htm


More information about the DBIx-Class mailing list