| Index
» Projekty
» phpMyEdit
» Fórum
» Joining 3 tables |
 |
dazil
Založený: 22.12.2007
Príspevky: 3
Zaslal: 2007-12-22 01:51
Návrat hore
Odpovedať s citátom
|
Hi everyone,
First of all, hats off to the development team. PHPMyEdit has saved me many hours of time and effort over the past few months, and I have recommended PHPMyEdit to several friends and colleagues since discovering it.
I have looked all over the forum for an answer to a problem I'm having.
I have 3 tables:
tblproducts
* id
* name
* description
* subcategory_id
tblsubcategories
* id
* category_id
* subcategory_desc
tblcategories
* id
* category_desc
I have a PHPMyEdit page which is used to edit records in tblproducts. I am able to successfully display the verbose subcategory name in the summary page, and am able to create a subcategory select list in the edit page, using syntax such as:
$opts['fdd']['subcategory_id']['values']['table']='tblsubcategories';
$opts['fdd']['subcategory_id']['values']['column']='id';
$opts['fdd']['subcategory_id']['values']['description'] = 'subcategory_desc';
Works like a charm so far.
I want to be able to display the verbose category in the summary, alongside the subcategory, and in the select list on the edit page (Eg. "TVs - Plasma" is a category-subcategory example).
Essentially, I need to display category_desc beside subcategory_desc, but of course the only field edited/inserted into tblproducts would be subcategory_id.
I have considered reorganizing the website which uses the data to allow subcategory_id and category_id to both be stored in the products table, however that seems redundant.
Your help is greatly appreciated.
Thanks,
dave
|
dazil
Založený: 22.12.2007
Príspevky: 3
Zaslal: 2008-01-01 19:29
Návrat hore
Odpovedať s citátom
|
Hi everyone,
I'm still seeking a solution -- any assistance would be greatly appreciated.
Thanks,
dave
|
robertut
Založený: 04.11.2008
Príspevky: 4
Zaslal: 2008-11-04 17:31
Návrat hore
Odpovedať s citátom
|
Dear all,
I am trying to find the solution for a similar problem. I have 3 tables:
table "errors":
id_err tower_id datetime duration reason
table "towers":
id_tower nametower power freq prog_id comment
table "programs":
id_prog nameprog comment
I wish to display, while editing the "errors" table with phpMyEdit, based on tower_id in a column (dropdown box):
towers.name, programs.name, towers.power
I did this:
$main_table = 'towers';
$main_column = 'prog_id';
$join_table = 'programs';
$join_column = 'id_prog';
$join_description = 'nameprog';
$opts['fdd']['ado']['values']['join'] = '$main_table.$main_column = $join_table.$join_column';
$opts['fdd']['ado']['values']['table'] = $main_table;
$opts['fdd']['ado']['values']['column'] = $main_column;
$opts['fdd']['ado']['values']['description']['columns'][0] = 'nametower';
$opts['fdd']['ado']['values']['description']['divs'][0] = ', ';
$opts['fdd']['ado']['values']['description']['columns'][1] = $join_description;
$opts['fdd']['ado']['values']['description']['divs'][1] = ', ';
$opts['fdd']['ado']['values']['description']['columns'][2] = 'freq';
$opts['fdd']['ado']['values']['description']['divs'][2] = ' MHz';
But I keep getting this:
MySQL error 1054
Unknown column 'PMEjoin1.nameprog' in 'field list'
What am I doing wrong?
Thanks in advance for your help.
|
robertut
Založený: 04.11.2008
Príspevky: 4
Zaslal: 2008-11-13 10:21
Návrat hore
Odpovedať s citátom
|
Any help, please?
I don't find any reference in the documentation, on what to do with $join_description.
You help is much appreciated.
|
robertut
Založený: 04.11.2008
Príspevky: 4
Zaslal: 2008-11-13 14:02
Návrat hore
Odpovedať s citátom
|
Is there at least a way to see the PMEJoin1 table? I'd like to see the contents of it, to be able do debug wether the joined table is good or not, and where am I mistaking.
Currently I have got no clue where is my mistake.
Please, help!
|
robertut
Založený: 04.11.2008
Príspevky: 4
Zaslal: 2008-11-14 14:06
Návrat hore
Odpovedať s citátom
|
| doug Napísal: |
| robertut Napísal: |
| I don't find any reference in the documentation, on what to do with $join_description. |
There's an example in the documentation:
http://opensource.platon.sk/projects/doc.php/phpMyEdit/html/configuration.input-restrictions.html#AEN1011
I don't think you can join 3 tables in the requested manner. Proabably it is time for straight PHP code to do this (not phpMyEdit). I've had an awful time getting join to work with 2 tables (not enough brain cells) and can't find a working example to join even 2 tables. |
Thanks for the answer, at least we know it's not possible.
Unfortunately the example in the documentation doesn't show the possibilities of the usage of $join_description. It only shows how to use $main_table, $main_column, $join_table, $join_column , but not $join_description.
|
|
Odoslať novú tému
Odpovedať na tému
|
|
|
|