Re: [Dave] List data from table in Detail page
Hi Dave,
I'm working with InstantRealty. What if you have three or more related tables that you want to display in the Listings page? I'm trying to do a LeftJoin but it only works with one table joining one table. I need to filter the listings by at least one field in the second table and also by another field in the third table.
Here is what I have so far.
require_once "cmsadmin/lib/viewer_functions.php";
list($residencesRecords, $residencesMetaData) = getRecords(array(
'tableName' => 'residences',
'perPage' => '10',
'orderBy' => 'residences.feature_end_date DESC, residences.listing_date DESC',
'allowSearch' => '0',
'leftJoin' => array(
'agencies' => 'ON (residences.agency_id= agencies.num)',
),
'leftJoin' .=> array(
'agents' => 'ON residences.agent_id= agents.num' ,
),
'where' => 'agents.currstatus=\'Active\' and agencies.currstatus=\'Active\' and residences.listing_type = \'Buy\'and residences.status = \'Active\'',
));
//Plain SQL that achieves the list of properties I want
//select * from irw_residences left join (irw_agents, irw_agencies) on (irw_residences.num=irw_agents.num and irw_residences.num=irw_agencies.num) where irw_agents.currstatus='Active' and irw_agencies.currstatus='Active' and irw_residences.listing_type='Buy' and irw_residences.status='Active'
Waiting to hear. Hope you can help.