From 893addeeceb0a60a323827809b89c5cb67478826 Mon Sep 17 00:00:00 2001 From: sparkyx Date: Sun, 6 Feb 2005 01:27:11 +0000 Subject: [PATCH] Improve dbconnect to permit setup.php to work --- include/ac_common.php | 6 ------ include/constant.php | 2 +- include/postgres.php | 44 ++++++++++++++++++++++++++++--------------- 3 files changed, 30 insertions(+), 22 deletions(-) diff --git a/include/ac_common.php b/include/ac_common.php index f8220f447..cb0a55cdd 100644 --- a/include/ac_common.php +++ b/include/ac_common.php @@ -145,12 +145,6 @@ $bg=""; else { $s=pg_fetch_array($Res,0); $style=$s['the_filestyle']; - // TO FIX - // Ugly but I cannot change the background color thanks CSS !!!! - /* $bg="bgcolor=white"; - if ($style=="style-aqua.css") $bg="bgcolor=\"#E3F0FF\""; - if ($style=="style-elegant.css") $bg="bgcolor=\"#E3F0FF""; - */ } echo ''; echo ""; diff --git a/include/constant.php b/include/constant.php index 9b1540b40..03221a2b2 100644 --- a/include/constant.php +++ b/include/constant.php @@ -23,7 +23,7 @@ // $Revision$ define ("phpcompta_password","dany"); -define ("DEBUG","true"); +define ("DEBUG","false"); // securite correspond a la table // action diff --git a/include/postgres.php b/include/postgres.php index 1d2447ca8..37efcddda 100644 --- a/include/postgres.php +++ b/include/postgres.php @@ -72,15 +72,21 @@ function ShowDossier($p_type,$p_first=0,$p_max=10,$p_Num=0) { function DbConnect($p_db=-1,$p_type='dossier') { if ( $p_db==-1) $l_dossier="account_repository"; - else - if ( $p_type == 'dossier') - $l_dossier=sprintf("dossier%d",$p_db); + else { + if ( $p_db == -2 ) + $l_dossier=$p_type; else - $l_dossier=sprintf("mod%d",$p_db); - - + switch ($p_type) { + case 'dossier': + $l_dossier=sprintf("dossier%d",$p_db); + break; + case 'mod': + $l_dossier=sprintf("mod%d",$p_db); + break; + } + } $password=phpcompta_password; - $a=pg_pconnect("dbname=$l_dossier host=127.0.0.1 user='phpcompta' password='$password'"); + $a=pg_connect("dbname=$l_dossier host=127.0.0.1 user='phpcompta' password='$password'"); echo_debug ("connect to $p_db"); return $a; } @@ -101,8 +107,8 @@ function ExecSql($p_connection, $p_string) { return $ret; } -/* - * GetAllUser + +/* function GetAllUser * Return all the users * as an array */ @@ -119,7 +125,7 @@ function GetAllUser() { } return $User; } -/* GetUid +/* function GetUid * Check if the User is valid * and return an array with his property */ @@ -133,8 +139,7 @@ function GetUid($p_uid) { } return $Prop; } -/* - * GetPriv +/* function GetPriv * Get the privilege of an user on a folder */ function GetPriv($p_dossier,$p_login) @@ -153,7 +158,7 @@ function GetPriv($p_dossier,$p_login) } return $Priv; } -/* ExisteJnt +/* function ExisteJnt * Get the number of rows * from table jnt_use_dos where $p_dossier = dos_id and * use_id=$p_user @@ -218,7 +223,7 @@ function CountSql($p_conn,$p_sql) return pg_NumRows($r_sql); } -/* GetDossierName +/* function GetDossierName * Param: id of a dossier * return : Name of the dossier */ @@ -229,7 +234,7 @@ function GetDossierName($p_dossier) $r= pg_fetch_array($Ret,0); return $r['dos_name']; } -/* GetSequence +/* function GetSequence * get the current sequence */ function GetSequence($p_cn,$p_seq) @@ -238,6 +243,15 @@ function GetSequence($p_cn,$p_seq) $seq=pg_fetch_array($Res,0); return $seq['seq']; } +/* function NextSequence + * get the current sequence + */ +function NextSequence($p_cn,$p_seq) +{ + $Res=ExecSql($p_cn,"select nextval('$p_seq') as seq"); + $seq=pg_fetch_array($Res,0); + return $seq['seq']; +} function StartSql($p_cn) { $Res=ExecSql($p_cn,"start transaction"); }