From 93ffb68cf23e27d1db0d4e9375c5853e1dd5c650 Mon Sep 17 00:00:00 2001
From: renato <renato@rezo.net>
Date: Mon, 31 Dec 2007 11:30:03 +0000
Subject: [PATCH] Introduction de $boucle->from_type pour assigner le type du
 jointure (INNER,LEFT,RIGHT). $boucle->from_type est un tableau du type
 array(alias du table => type_jointure, ...) C'est pas necessaire mais
 possible a declarer le type du jointure pour le cas INNER

---
 ecrire/public/compiler.php   | 10 ++++++++++
 ecrire/public/composer.php   |  5 +++--
 ecrire/public/interfaces.php |  1 +
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/ecrire/public/compiler.php b/ecrire/public/compiler.php
index 9a314706d0..48293f30fc 100644
--- a/ecrire/public/compiler.php
+++ b/ecrire/public/compiler.php
@@ -300,6 +300,8 @@ function calculer_requete_sql(&$boucle)
 		'"), # SELECT
 		' . calculer_from($boucle) .
 		', # FROM
+		' . calculer_from_type($boucle) .
+		', # FROM	type jointure	
 		' . calculer_dump_array($boucle->where) .
 		', # WHERE
 		' . calculer_dump_join($boucle->join)
@@ -351,6 +353,14 @@ function calculer_from(&$boucle)
   return 'array(' . substr($res,1) . ')';
 }
 
+// http://doc.spip.org/@calculer_from_type
+function calculer_from_type(&$boucle)
+{
+  $res = "";
+  foreach($boucle->from_type as $k => $v) $res .= ",'$k' => '$v'";
+  return 'array(' . substr($res,1) . ')';
+}
+
 // http://doc.spip.org/@calculer_order
 function calculer_order(&$boucle)
 {
diff --git a/ecrire/public/composer.php b/ecrire/public/composer.php
index 505a7ddb20..6036f6ae1b 100644
--- a/ecrire/public/composer.php
+++ b/ecrire/public/composer.php
@@ -471,7 +471,8 @@ function lang_parametres_forum($qs, $lang) {
 
 // http://doc.spip.org/@calculer_select
 function calculer_select ($select = array(), $from = array(), 
-			$where = array(), $join=array(),
+			$from_type = array(),
+      $where = array(), $join=array(),
 			$groupby = array(), $orderby = array(), $limit = '',
 			$having=array(), $table = '', $id = '', $serveur='') {
 
@@ -509,7 +510,7 @@ function calculer_select ($select = array(), $from = array(),
 		OR calculer_jointnul($cle, $select)
 		OR calculer_jointnul($cle, $join)
 		OR calculer_jointnul($cle, $where))
-			$sfrom = "\n\tINNER JOIN " . $from[$cle] . " AS $cle ON $t.$c=$cle.$c" . $sfrom;
+      $sfrom = "\n\t".(isset($from_type[$cle])?$from_type[$cle]:"INNER")." JOIN " . $from[$cle] . " AS $cle ON $t.$c=$cle.$c" . $sfrom;
 		else { unset($join[$k]);}
 		unset($from[$cle]);
 	}
diff --git a/ecrire/public/interfaces.php b/ecrire/public/interfaces.php
index 18a7706c37..fe209f50db 100644
--- a/ecrire/public/interfaces.php
+++ b/ecrire/public/interfaces.php
@@ -57,6 +57,7 @@ class Boucle {
 	// champs pour la construction de la requete SQL
 	var $select = array();
 	var $from = array();
+	var $from_type = array();
 	var $where = array();
 	var $join = array();
 	var $having = array();
-- 
GitLab