diff --git a/ecrire/public/criteres.php b/ecrire/public/criteres.php index 642ac47c363206eb5086148095b19d8ae5416288..92c1d03b197ed68d66c786e622b16065a1e6a9c5 100644 --- a/ecrire/public/criteres.php +++ b/ecrire/public/criteres.php @@ -687,11 +687,15 @@ function calculer_chaine_jointures(&$boucle, $depart, $arrivee, $vu=array()) list($anom,$adesc) = $arrivee; $keys = $ddesc['key']; - + if ($v = $adesc['key']['PRIMARY KEY']) { + unset($adesc['key']['PRIMARY KEY']); + $akeys = array_merge(preg_split('/,\s*/', $v), $adesc['key']); + } + else $akeys = $adesc['key']; // priorite a la primaire, qui peut etre multiple - if ($v = (split(', *', $keys['PRIMARY KEY']))) + if ($v = (preg_split('/,\s*/', $keys['PRIMARY KEY']))) $keys = $v; - $v = array_intersect($keys, $adesc['key']); + $v = array_intersect($keys, $akeys); if ($v) return array(array($dnom, $arrivee, array_shift($v))); else { diff --git a/ecrire/public/references.php b/ecrire/public/references.php index 3ca07787cc65e5a5efc97d39a0eb70dccf49d2ac..e9cf216a15c798c52efafbdfc2fb48837fd18242 100644 --- a/ecrire/public/references.php +++ b/ecrire/public/references.php @@ -101,7 +101,7 @@ function description_type_requete($type, $serveur='') { } function index_tables_en_pile($idb, $nom_champ, &$boucles) { - global $exceptions_des_tables, $tables_des_serveurs_sql; + global $exceptions_des_tables; $r = $boucles[$idb]->type_requete; $s = $boucles[$idb]->sql_serveur; @@ -128,8 +128,11 @@ function index_tables_en_pile($idb, $nom_champ, &$boucles) { $t = trouver_champ_exterieur($nom_champ, $boucles[$idb]->jointures, $boucles[$idb]); - if ($t) $t = array_search($t[0], $boucles[$idb]->from); - if ($t) return array($t .'.' . $nom_champ, $nom_champ); + if ($t) + return index_exception($boucles[$idb], + $desc, + $nom_champ, + array($t[0], $nom_champ)); } return array('',''); }