Skip to content
Extraits de code Groupes Projets
Valider 93ffb68c rédigé par renato's avatar renato
Parcourir les fichiers

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
parent 792fa7db
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -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)
{
......
......@@ -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]);
}
......
......@@ -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();
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter