Get file uploads from a joined table

5 posts by 3 authors in: Forums > CMS Builder
Last Post: November 1, 2012   (RSS)

By sykomac - February 6, 2010

I have two databases: programs and program_addresses

program_addresses has an upload field allowing upload of 1 image

I create a Select on programs database with a leftJoin on program_addresses

list($programsRecords, $programsMetaData) = getRecords(array(
'tableName' => 'programs',
'allowSearch' => '0',
'loadUploads' => 'yes',
'where' => 'start_time <= "2110" AND end_time >= "2110" AND day LIKE "%Sat%"',
'leftJoin' => array(
'program_addresses' => 'program',
),

));


The search finds the correct matching records but I am not able to get access to the upload field from the program_addresses database.

Am I missing something?

Re: [sykomac] Get file uploads from a joined table

By Dave - February 8, 2010

Hi sykomac,

The 'leftJoin' option doesn't yet support loading uploads for the joined table.

So, it could be a bit tricky. You could try doing a separate getRecords() call for 'program_addresses' with a where that loaded the records you wanted based on some criteria from the previous table you loaded.

How many programs are you displaying on a page?
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Get file uploads from a joined table

Any idea when this functionality will be available?

Re: [tmudford] Get file uploads from a joined table

By Dave - November 1, 2012

Hi tmudford,

We don't have any current plans for further automatic support of joins or loading of uploads.

If you're already doing a custom mysql query with a join you can always just do another query to get the uploads.

If you have records from a single table, or just want to reference some MySQL code for loading uploads, you could take a look at the functions addUploadsToRecords(), and addUploadsToRecord() in /lib/upload_functions.php

Hope that helps!
Dave Edis - Senior Developer
interactivetools.com