Re: [jdancisin] JOIN question... I think
Hi jdancisin,
When you setup the related contact field, be sure to select "num" for the value field, and then title or name for the "label" field. Also, name your field contactNum.
Once you've done that, update a few records as they will have forgotten their old values.
Next, try this new leftJoin option in your viewer code that displays news:
// Note: leftJoins require you to use fully qualified fieldnames in WHERE and ORDER BY, such as tablename.fieldname
'leftJoin' => array(
// foreign table => local field (that matches num in foreign table)
'contacts' => 'contactNum',
),
This should load the contact fields as contacts.fieldname, eg: contacts.num, etc. Test this with this debug code to print out your $records array (which may be called newsRecords or something else:
<xmp><?php print_r($newsRecords); ?></xmp>
And then print out the values you want with something like this:
<?php echo $record['contacts.name'] ?>
Hope that made sense, let me know how it goes.
Dave Edis - Senior Developer
interactivetools.com