| Index
» Projects
» phpMyEdit
» Forum
» Advanced table lookup -- joining three tables |
 |
sagiben
Joined: 27 Jan 2009
Posts: 14
Posted: 2009-01-30 11:05
Back to top
Reply with quote
|
| sagiben wrote: |
Hi all,
Does anyone know if there is a similar patch for
phpMyEdit-mce-cal.class.php ?
I need to use the "multi join" option and a calender
in the same form.
Thank you. |
I found that no patch for phpMyEdit-mce-cal.class.php is needed
Thanks
|
paddywwoof
Joined: 25 Feb 2010
Posts: 7
Posted: 2010-02-25 18:32
Back to top
Reply with quote
|
In order to get this working with a combination of fields from the linked table as well as the linked-linked table I had to further modify the code to use unique aliases for the different tables
| Code: |
...
/**/ $tbl_count = 0;
foreach ($desc['columns'] as $key => $val) {
if ($val) {
$tbl_count++;
// $qparts['select'] .= 'IFNULL(CAST('.$this->sd.$val.$this->ed.' AS CHAR),"")';
/**/ //$qparts['select'] .= 'IFNULL(CAST('.$this->sd.$val.$this->ed.' AS CHAR),"")';
/**/ if ($desc['values'][$key]) {
/**/ $qparts['select'] .= 'IFNULL(CAST(PGtbl'.$field_num.'_'.$tbl_count.'.'.$desc['values'][$key]['description'].' AS CHAR),"")';
/**/ $qparts['from'] .= ", ".$dbp.$desc['values'][$key]['table']." AS PGtbl".$field_num."_".$tbl_count;
/**/ if ($qparts['where'] != '') $qparts['where'] .= ' AND ';
/**/ $qparts['where'] .= "$table.".$this->sd.$val.$this->ed." = PGtbl".$field_num."_".$tbl_count.".".$desc['values'][$key]['column'];
...
|
I have to use the linked table as the name for the second link in a rather ugly and unnecessary join. i.e. dividends.holdingID -> sh_holding.ID, sh_holding.StockID -> sh_stock.ID I have to link sh_holding to sh_holding in order to display the two fields (purchasedate and quantity) along with the description from sh_stock.name (!!) like:
| Code: |
$opts['fdd']['holdingID'] = array(
'name' => 'HoldingID',
'select' => 'T',
'values' => array(
'table' => 'sh_holding',
'column' => 'ID',
'description' => array(
'columns' => array('ID', 'ID', 'StockID'),
'divs' => array(' [', '] ',''),
'values' => array(
array(
'table' => 'sh_holding',
'column' => 'ID',
'description' => 'Purchdate'
),
array(
'table' => 'sh_holding',
'column' => 'ID',
'description' => 'quantity'
),
array(
'table' => 'sh_stock',
'column' => 'ID',
'description' => 'name'
)
)
)
),
|
|
sagiben
Joined: 27 Jan 2009
Posts: 14
Posted: 2010-08-18 09:36
Back to top
Reply with quote
|
I think the best way to make phpMyEdit read/update date from more then 2 tables is just create a view in mysql with all the data one need and refer to this new table from phpMyEdit.
A view is a virtual table that is defined in advance but it gets the data in runtime.
One can create a view which contains a join of 3 tables and more and use it like it is a regular table.
Sagi.
|
|
Post new topic
Reply to topic
Goto page Previous 1, 2, 3
|
|
|
|