From ee8d3ff5e662682ecf5a97545ea6dc6cfce64637 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 24 Mar 2010 13:26:27 +0000 Subject: [PATCH] Fix: Postgres compatibility --- htdocs/compta/index.php | 6 +++--- htdocs/lib/databases/pgsql.lib.php | 5 ++++- htdocs/lib/project.lib.php | 4 ++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index dea4efcefc7..c209ec78fcf 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2009 Laurent Destailleur + * Copyright (C) 2004-2010 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * * This program is free software; you can redistribute it and/or modify @@ -405,7 +405,7 @@ if ($conf->fournisseur->enabled && $user->rights->fournisseur->facture->lire) $sql.= " AND s.entity = ".$conf->entity; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; if ($socid) $sql.= " AND ff.fk_soc = ".$socid; - $sql.= " GROUP BY ff.rowid, ff.facnumber, ff.fk_statut, ff.libelle, ff.total_ht, ff.total_ttc, ff.tms, s.nom, s.rowid"; + $sql.= " GROUP BY ff.rowid, ff.facnumber, ff.fk_statut, ff.libelle, ff.total_ht, ff.total_ttc, ff.tms, ff.paye, s.nom, s.rowid"; $sql.= " ORDER BY ff.tms DESC "; $sql.= $db->plimit($max, 0); @@ -588,7 +588,7 @@ if ($conf->tax->enabled && $user->rights->tax->charges->lire) $sql = "SELECT c.rowid, c.amount, c.date_ech, c.paye,"; $sql.= " cc.libelle,"; - $sql.= " sum(pc.amount) as sumpaid"; + $sql.= " SUM(pc.amount) as sumpaid"; $sql.= " FROM (".MAIN_DB_PREFIX."chargesociales as c, ".MAIN_DB_PREFIX."c_chargesociales as cc)"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiementcharge as pc ON c.rowid = pc.fk_charge"; $sql.= " WHERE c.fk_type = cc.id"; diff --git a/htdocs/lib/databases/pgsql.lib.php b/htdocs/lib/databases/pgsql.lib.php index 3f54edfc021..079836ba53e 100644 --- a/htdocs/lib/databases/pgsql.lib.php +++ b/htdocs/lib/databases/pgsql.lib.php @@ -249,9 +249,12 @@ class DoliDb //print $line; // Remove () in the tables in FROM if two table - //$line=preg_replace('/FROM\s*\((([a-z_]+)\s+as\s+([a-z_]+)\s*,\s*([a-z_]+)\s+as\s+([a-z_]+)\s*)\)/i','FROM \\1',$line); + $line=preg_replace('/FROM\s*\(([a-z_]+\s+as\s+[a-z_]+)\s*,\s*([a-z_]+\s+as\s+[a-z_]+\s*)\)/i','FROM \\1, \\2',$line); //print $line; + // Remove () in the tables in FROM if two table + $line=preg_replace('/FROM\s*\(([a-z_]+\s+as\s+[a-z_]+)\s*,\s*([a-z_]+\s+as\s+[a-z_]+\s*),\s*([a-z_]+\s+as\s+[a-z_]+\s*)\)/i','FROM \\1, \\2, \\3',$line); + //print $line; } # END of if ($create_sql ne "") i.e. were inside create table statement so processed datatypes else { # not inside create table #---- fix data in inserted data: (from MS world) diff --git a/htdocs/lib/project.lib.php b/htdocs/lib/project.lib.php index 9b24d630a37..ec954617e83 100644 --- a/htdocs/lib/project.lib.php +++ b/htdocs/lib/project.lib.php @@ -578,13 +578,13 @@ function print_projecttasks_array($db,$mine,$socid,$projectsListId) print_liste_field_titre($langs->trans("Status"),"","","","",'align="right"',$sortfield,$sortorder); print "\n"; - $sql = "SELECT p.rowid as projectid, p.ref, p.title, p.fk_user_creat, p.public, p.fk_statut, count(t.rowid) as nb"; + $sql = "SELECT p.rowid as projectid, p.ref, p.title, p.fk_user_creat, p.public, p.fk_statut, COUNT(t.rowid) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t ON p.rowid = t.fk_projet"; $sql.= " WHERE p.entity = ".$conf->entity; if ($mine) $sql.= " AND p.rowid IN (".$projectsListId.")"; if ($socid) $sql.= " AND p.fk_soc = ".$socid; - $sql.= " GROUP BY p.ref"; + $sql.= " GROUP BY p.rowid, p.ref, p.title, p.fk_user_creat, p.public, p.fk_statut"; $var=true; $resql = $db->query($sql);