From d2d12e46afb97d1ea315ecfd96715d4544554692 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Mon, 25 Jul 2016 11:25:25 +0200 Subject: [PATCH] ORM : Correction du SELECT (placement de la ',' avec gestion des fonctions et du 'distinct' --- manager/ORM/SQLBuilder.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/manager/ORM/SQLBuilder.php b/manager/ORM/SQLBuilder.php index 67e002f..58e182b 100644 --- a/manager/ORM/SQLBuilder.php +++ b/manager/ORM/SQLBuilder.php @@ -262,7 +262,7 @@ foreach($fields as $field=>$select){ /* (1) On construit le nom du champ */ - $fieldStr = ($c==0) ? "$table.$field" : ", $table.$field"; + $fieldStr = "$table.$field"; /* (2) On ajout le DISTINCT s'il y a lieu */ if( isset($select[1]) && $select[1] ) @@ -275,10 +275,11 @@ /* (4) On ajoute l'alias */ if( isset($select[0]) && !is_null($select[0]) ) - $sql .= "$fieldStr as agg_$field"; + $fieldStr = "$fieldStr as agg_$field"; else - $sql .= "$fieldStr"; + $fieldStr = "$fieldStr"; + $sql .= ($c==0) ? "$fieldStr" : ", $fieldStr"; $c++; }