phpMyEdit - Viewing Bug Advanced Details [ Go Back ]
169 core / field option feature N/A 2004-01-25 15:39 2006-09-01 17:24
hbernard PC  
(Server) Linux Mandrake 9.1  
normal Builtin  
feedback  
open  
none  
none  
Making multiple select and 'values''table' working together
Currently, it is not possible to have multiple select values filled from an external table.

The only source for multiple select seems to be Values or Values2 array.
Use ['values']['table'] with 'select' => 'M' together.

You ll have multiple select in Filter mode but not in A/C mode.
Idea come from :
http://platon.sk/forum/projects/viewtopic.php?t=116

ugly patch is :
//<hbernard - Line 2650 - hack to make 'M'ultiple work with ['values']['table']
if ($this->fdd[$key]['select'] == 'M' && isset($this->fdd[$key]['values']['table'])) {
$this->connect(); //connection to mysql, required for set_values_from....
$this->fdd[$key]['values2'] = (array)$this->fdd[$key]['values2']
+ (array)$this->set_values_from_table($key);
unset($this->fdd[$key]['values']); //useless values
}
//>hbernard

Bug Notes
hbernard   
2004-01-30 15:40   
hack above is confirmed to be correct (but still ugly).
See : http://platon.sk/forum/projects/viewtopic.php?t=116
hbernard   
2004-04-14 16:41   
More rationnales about this :
- currently, multiple select is not possible when values come from an external table. (values-table has precedence to multiple select).
- But multiple select handle very well the storage of ID in the field, using values2.

Issue is : Why not fix PME in order to allow multiple select field to be filled with an external table.

Pros :
- this is an easy fix.
- this allow quick m:n bindings workaround for phpMyEdit.

Cons :
- The way the patch is made is a bit hacky : get values from table, append in values2, unset values
- this is not state_of_database_art

Nepto and others pme hackers, may I have your feedback on this.

edited on: 2004-04-14 22:40
nepto   
2004-04-14 19:40   
Well this is actually true? I thought that it is possible to fill in multiple select from external table. well if not, it is certainlly bug and should be fixed.

The patch is horrible, but I believe it may work.

There must be and cleaner way. I aggre that this is quite usable workaround for m:n bindings. People are not forced to use it, if they think "this is not state_of_database_art". ;-)
hbernard   
2004-04-14 22:25   
I just remember why I came to this horrible patch (Was 3 months ago, you know ;-) :

If you don't unset 'values', join will be performed and that's stupid because if field is multiple, this is not a true foreign key.

(This is a very sad but true side effect of an API which allow mixed arguments for mixed purpose, like 'values'.)

So I see two ways :
1- stick with the ugly-but-working patch

2-
+ remove the test on 'values''table' in has_multiple_select
+ don't make the join if has_multiple_select
+ remove some random test on 'values''table' floating around
+ i wonder what else

(2) is harder but cleaner, I will try this one if you agree

edited on: 2004-04-14 22:39

edited on: 2004-04-16 11:56
valedo   
2006-09-01 17:24   
hbernard thnx for this patch.
But nepto, please fix this bug NOT "horrible"!

:))