From 2db96eecaef47f9c024ad9679aaa66498e4ead44 Mon Sep 17 00:00:00 2001 From: "Committo,Ergo:sum" <esj@rezo.net> Date: Wed, 28 Nov 2007 16:04:17 +0000 Subject: [PATCH] =?UTF-8?q?Centralisation=20des=20d=C3=A9clarations=20de?= =?UTF-8?q?=20jointures=20dans=20le=20compilateur.=20Toutesles=20requ?= =?UTF-8?q?=C3=AAtes=20produites=20sont=20bien=20des=20INNER=20JOIN.=20A?= =?UTF-8?q?=20contrario,=20ceci=20veut=20dire=20qu'il=20manque=20des=20cri?= =?UTF-8?q?t=C3=A8res=20pour=20produire=20des=20OUTER=20JOIN,=20par=20exem?= =?UTF-8?q?ple=20celui=20des=20url=5Fpropres.=20Il=20faudra=20y=20revenir.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ecrire/public/boucles.php | 6 ++---- ecrire/public/references.php | 17 ++++++++--------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/ecrire/public/boucles.php b/ecrire/public/boucles.php index 68a4e711f7..d03e017c80 100644 --- a/ecrire/public/boucles.php +++ b/ecrire/public/boucles.php @@ -290,10 +290,8 @@ function boucle_SYNDIC_ARTICLES_dist($id_boucle, &$boucles) { else { $jointure = array_search("spip_syndic", $boucle->from); if (!$jointure) { - $jointure = 'J' . count($boucle->from); - $boucle->from[$jointure] = 'spip_syndic'; - $boucle->where[]= array("'='", "'$id_table" .".id_syndic'", - "\"$jointure" . '.id_syndic"'); + fabrique_jointures($boucle, array(array($id_table, array('spip_syndic'), 'id_syndic')), true, $boucle->show, $id_table); + $jointure = array_search('spip_syndic', $boucle->from); } $boucle->where[]= array("'='", "'$mstatut'", "'\\'publie\\''"); $boucle->where[]= array("'='", "'$jointure" . ".statut'", "'\\'publie\\''"); diff --git a/ecrire/public/references.php b/ecrire/public/references.php index c053cff202..ab90a713df 100644 --- a/ecrire/public/references.php +++ b/ecrire/public/references.php @@ -43,8 +43,9 @@ function index_pile($idb, $nom_champ, &$boucles, $explicite='') { while (isset($boucles[$idb])) { list ($t, $c) = index_tables_en_pile($idb, $nom_champ, $boucles); if ($t) { - if (!in_array($t, $boucles[$idb]->select)) + if (!in_array($t, $boucles[$idb]->select)) { $boucles[$idb]->select[] = $t; + } return '$Pile[$SP' . ($i ? "-$i" : "") . '][\'' . $c . '\']'; } # spip_log("On remonte vers $i"); @@ -117,17 +118,15 @@ function index_exception(&$boucle, $desc, $nom_champ, $excep) if ($t == NULL) { list($e, $x) = $excep; #PHP4 affecte de gauche a droite $excep = $x; #PHP5 de droite a gauche ! + $j = $trouver_table($e, $boucle->sql_serveur); + if (!$j) return array('',''); + $e = $j['table']; if (!$t = array_search($e, $boucle->from)) { - $j = $trouver_table($e, $boucle->sql_serveur); - if ($j) { - $t = 'J' . count($boucle->from); - $boucle->from[$t] = $j['table']; - $j = $j['key']['PRIMARY KEY']; - $boucle->where[]= array("'='", "'$boucle->id_table." . "$j'", "'$t.$j'"); - } + fabrique_jointures($boucle, array(array($boucle->id_table, array($j['table']), $j['key']['PRIMARY KEY']))); + $t = array_search($e, $boucle->from); } } - } + } else $t = $boucle->id_table; // demander a SQL de gerer le synonyme // ca permet que excep soit dynamique (Cedric, 2/3/06) -- GitLab