X-Git-Url: https://git.cyclocoop.org/?a=blobdiff_plain;f=www%2Fecrire%2Freq%2Fpg.php;fp=www%2Fecrire%2Freq%2Fpg.php;h=66bd90f18e8def555c408dbd846d7afcc4a3504d;hb=ac3048660a3889c33f121bf5a567654e674e543a;hp=57d23e1186b243c2c47a5fa5f1842eb94606cae9;hpb=db106e5fbbef82fe8d4a95b1124113c2149ee37d;p=lhc%2Fweb%2Fwww.git diff --git a/www/ecrire/req/pg.php b/www/ecrire/req/pg.php index 57d23e11..66bd90f1 100644 --- a/www/ecrire/req/pg.php +++ b/www/ecrire/req/pg.php @@ -3,7 +3,7 @@ /* *************************************************************************\ * SPIP, Systeme de publication pour l'internet * * * - * Copyright (c) 2001-2012 * + * Copyright (c) 2001-2014 * * Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James * * * * Ce programme est un logiciel libre distribue sous licence GNU/GPL. * @@ -574,6 +574,10 @@ function spip_pg_groupby($groupby, $from, $select) if (!$groupby) return ''; $groupby = spip_pg_frommysql($groupby); + // Ne pas mettre dans le Group-By des valeurs numeriques + // issue de prepare_recherche + $groupby = preg_replace('/^\s*\d+\s+AS\s+\w+\s*,?\s*/i','', $groupby); + $groupby = preg_replace('/,\s*\d+\s+AS\s+\w+\s*/i','', $groupby); $groupby = preg_replace('/\s+AS\s+\w+\s*/i','', $groupby); return "\nGROUP BY $groupby"; @@ -1031,7 +1035,7 @@ function spip_pg_cite($v, $t){ if(is_null($v)) return 'NULL'; // null php se traduit en NULL SQL if (sql_test_date($t)) { - if (strpos("0123456789", $v[0]) === false) + if ($v AND (strpos("0123456789", $v[0]) === false)) return spip_pg_frommysql($v); else { if (strncmp($v,'0000',4)==0)