| Index
» Projekty
» phpMyEdit
» Fórum
» Patch for complex table joins |
 |
jestapher
Založený: 09.06.2003
Príspevky: 5
Zaslal: 2007-04-13 03:27
Návrat hore
Odpovedať s citátom
|
In 2003 I wrote a patch for 5.4 to do complex table joins. The original thread is at:
http://opensource.platon.sk/forum/projects/viewtopic.php?t=103
I've updated this patch for 5.6. It lives at:
http://inwa.net/~ben/phpmyedit56.multijoin.patch
To explain what this does, imagine my dilemma: I maintain a work scheduling application. The table "staff_to_shift" matches a staff id and a shift id, both of which reference other tables. The referenced shift table in turn references the crew table to get the crew name for the shift. With the basic phpMyEdit functionality, I can replace staff_to_shift.shift_id with "shift.crew_id - shift.start" which looks something like:
| Kód: |
| "22 - 2006-08-17 11:00:00" |
But I want the crew_id replaced with the crew name from the crew table, like this:
| Kód: |
| "Security - 2006-08-17 11:00:00" |
This patch makes it possible to do that. In your config file, after the column definition, add something like:
| Kód: |
// standard phpMyEdit options
$opts['fdd']['shift']['values']['table'] = '2007_shift';
$opts['fdd']['shift']['values']['column'] = 'id';
$opts['fdd']['shift']['values']['description']['columns'][0] = 'crew';
$opts['fdd']['shift']['values']['description']['columns'][1] = 'start';
$opts['fdd']['shift']['values']['description']['divs'][0] = ' ';
// patched phpMyEdit options
$opts['fdd']['shift']['values']['description']['values'][0]['table'] = 'crew';
$opts['fdd']['shift']['values']['description']['values'][0]['column'] = 'id';
$opts['fdd']['shift']['values']['description']['values'][0]['columns'] = 'name';
|
That will replace ['description']['columns'][0] with ['description']['values'][0]['columns'] -- replace 2007_shift.crew with 2007_crew.name. The patch works when viewing or editing records.
I think this patch is useful. I couldn't find any other way to do this. Apologies if I missed something in the docs.
-- Ben
|
pgowling
Založený: 20.02.2004
Príspevky: 6
Zaslal: 2007-06-11 20:34
Návrat hore
Odpovedať s citátom
|
Ben,
Do you know if this patch breaks the column filtering as I'm now getting an ambiguous column error since applying the patch which I wasn't before?
Regards,
Phil
|
pgowling
Založený: 20.02.2004
Príspevky: 6
Zaslal: 2007-06-11 20:41
Návrat hore
Odpovedať s citátom
|
This is followed by the error:
"Warning: Illegal offset type in /media/disk2/www/fpload/V2.0/admin/phpMyEdit.class.php on line 2924"
Is there an already patched version of the 5.6 class that I can download as it may by my doing that is causing these issues?
|
|
Odoslať novú tému
Odpovedať na tému
|
|
|
|