Skip to content
Extraits de code Groupes Projets
Valider d8c8dcc4 rédigé par esj's avatar esj
Parcourir les fichiers

calcul des chaines de jointures mieux initialisé: il produisait une jointure...

calcul des chaines de jointures mieux initialisé: il produisait une jointure d'une table a elle-meme dans certains cas.
parent 5ddabedd
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -169,8 +169,10 @@ function boucle_DOCUMENTS_dist($id_boucle, &$boucles) { ...@@ -169,8 +169,10 @@ function boucle_DOCUMENTS_dist($id_boucle, &$boucles) {
$boucle->where[]= "($id_table.taille > 0 OR $id_table.distant='oui')"; $boucle->where[]= "($id_table.taille > 0 OR $id_table.distant='oui')";
$jointure = array_search("spip_types_documents", $boucle->from); $jointure = array_search("spip_types_documents", $boucle->from);
if ($jointure) if ($jointure) {
$boucle->where[] = $id_table . ".id_type=$jointure" . ".id_type"; $j = $id_table . ".id_type=$jointure" . ".id_type";
if (!in_array($j, $boucle->join)) $boucle->join[]= $j;
}
return calculer_boucle($id_boucle, $boucles); return calculer_boucle($id_boucle, $boucles);
} }
......
...@@ -643,8 +643,14 @@ function calculer_chaine_jointures(&$boucle, $depart, $arrivee, $vu=array()) ...@@ -643,8 +643,14 @@ function calculer_chaine_jointures(&$boucle, $depart, $arrivee, $vu=array())
{ {
list($dnom,$ddesc) = $depart; list($dnom,$ddesc) = $depart;
list($anom,$adesc) = $arrivee; list($anom,$adesc) = $arrivee;
$prim = $ddesc['key']['PRIMARY KEY'];
$v = array_intersect($prim ? split(', *',$prim): $ddesc['key'], $adesc['key']); $keys = $ddesc['key'];
if ($v = $keys['PRIMARY KEY']) {
unset($keys['PRIMARY KEY']);
$keys = array_merge(split(', *', $v), $keys);
}
$v = array_intersect($keys, $adesc['key']);
if ($v) if ($v)
return array(array($dnom, $arrivee, array_shift($v))); return array(array($dnom, $arrivee, array_shift($v)));
else { else {
...@@ -653,7 +659,7 @@ function calculer_chaine_jointures(&$boucle, $depart, $arrivee, $vu=array()) ...@@ -653,7 +659,7 @@ function calculer_chaine_jointures(&$boucle, $depart, $arrivee, $vu=array())
if ($v && (!in_array($v,$vu)) && if ($v && (!in_array($v,$vu)) &&
($def = trouver_def_table($v, $boucle))) { ($def = trouver_def_table($v, $boucle))) {
list($table,$join) = $def; list($table,$join) = $def;
$milieu = array_intersect($ddesc['key'], trouver_cles_table($join['key'])); $milieu = array_intersect($keys, trouver_cles_table($join['key']));
foreach ($milieu as $k) foreach ($milieu as $k)
{ {
$new[] = $v; $new[] = $v;
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter