Main Page | Namespace List | Class Hierarchy | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

setup.php File Reference

This file permit to upgrade a version of phpcompta, it should be used and immediately delete after an upgrade. This file is included in each release for a new upgrade. More...

Go to the source code of this file.

Functions

 GetVersion ($p_cn)
 ExecuteScript ($p_cn, $script)

Variables

 $inc_path = get_include_path()
 $flag_php = 0
 $sql = "select lanname from pg_language where lanname='plpgsql'"
 $Res = CountSql($cn,$sql)
 $flag = 0
 $a = DbConnect()
else print Connect to database success< br >
 $cn = DbConnect()
 $Resdossier = ExecSql($cn,"select dos_id, dos_name from ac_dossier")
 $MaxDossier = pg_NumRows($Resdossier)
 $db = DbConnect($db_row['dos_id'],'dossier')
 $Max = pg_NumRows($Res)
 $Res2 = ExecSql($db,'select coalesce(max(jr_grpt_id),1) as l from jrn')
 $Max2 = pg_NumRows($Res2)
 $M = $Row['l']


Detailed Description

This file permit to upgrade a version of phpcompta, it should be used and immediately delete after an upgrade. This file is included in each release for a new upgrade.

Todo:
remove the rebuild of mod2 (drop / create) for the next version the mod2 from the version < 2.0 are full of bugs

Definition in file setup.php.


Function Documentation

ExecuteScript p_cn,
script
 

Definition at line 104 of file setup.php.

References $sql, ExecSql(), exit, print, and Rollback().

00104                                       {
00105   $hf=fopen($script,'r');
00106   if ( $hf == false ) {
00107           echo 'Ne peut ouvrir '.$script;
00108           exit();
00109           }
00110   $sql="";
00111   $flag_function=false;
00112   while (!feof($hf)) {
00113     $buffer=fgets($hf);
00114     $buffer=str_replace ("$","\$",$buffer);
00115     print $buffer."<br>";
00116     // comment are not execute
00117     if ( substr($buffer,0,2) == "--" ) {
00118       //echo "comment $buffer";
00119       continue;
00120     }
00121     // Blank Lines Are Skipped
00122     If ( Strlen($buffer)==0) {
00123             //echo "Blank $buffer";
00124       Continue;
00125     }
00126     if ( strpos(strtolower($buffer),"create function")===0 ) {
00127             echo "found a function";
00128             $flag_function=true;
00129             $sql=$buffer;
00130             continue;
00131     }
00132  if ( strpos(strtolower($buffer),"create or replace function")===0 ) {
00133             echo "found a function";
00134             $flag_function=true;
00135             $sql=$buffer;
00136             continue;
00137     }
00138     // No semi colon -> multiline command
00139     if ( $flag_function== false && strpos($buffer,';') == false ) {
00140       $sql.=$buffer;
00141       continue;
00142     } 
00143     if ( $flag_function ) {
00144       if ( strpos(strtolower($buffer), "language plpgsql") === false && 
00145            strpos(strtolower($buffer), "language 'plpgsql'") === false ) {
00146                 $sql.=$buffer;
00147                 continue;
00148             }
00149     } else  {
00150             // cut the semi colon
00151             $buffer=str_replace (';','',$buffer);
00152             }
00153     $sql.=$buffer;
00154     if ( ExecSql($p_cn,$sql) == false ) {
00155             Rollback($p_cn);
00156             if ( DEBUG=='false' ) ob_end_flush();
00157             print "ERROR : $sql";
00158             exit();
00159             }
00160     $sql="";
00161     $flag_function=false;
00162     print "<hr>";
00163   } // while (feof)
00164   fclose($hf);
00165 }

GetVersion p_cn  ) 
 

Definition at line 87 of file setup.php.

References $a, $Res, and ExecSql().

00087                            {
00088         $Res=ExecSql($p_cn,"select val from version");
00089         $a=pg_fetch_array($Res,0);
00090         return $a['val'];
00091 }


Variable Documentation

$a = DbConnect()
 

Definition at line 377 of file setup.php.

$cn = DbConnect()
 

Definition at line 390 of file setup.php.

$db = DbConnect($db_row['dos_id'],'dossier')
 

Definition at line 396 of file setup.php.

Referenced by ViewJrn().

$flag = 0
 

Definition at line 269 of file setup.php.

Referenced by AddFiche(), ComputeTotalVat(), FormFin(), FormODS(), and fiche::getAttribut().

$flag_php = 0
 

Definition at line 179 of file setup.php.

$inc_path = get_include_path()
 

Definition at line 63 of file setup.php.

$M = $Row['l']
 

Definition at line 438 of file setup.php.

Referenced by DisplayDetailModele(), and Balance::GetRow().

$Max = pg_NumRows($Res)
 

Definition at line 404 of file setup.php.

Referenced by EncodeFiche(), FormPeriode(), FormPeriodeMult(), Get_fiche_def_ref(), fiche::getAttribut(), GetDataForm(), GetDataGrpt(), GetDataJrn(), GetDataJrnPdf(), GetDataModele(), GetDataPoste(), GetFicheJrn(), cl_user::GetGlobalPref(), GetJrnName(), jrn::GetName(), GetNextFiche(), rapport::GetRow(), poste::GetRow(), jrn::GetRow(), GetSolde(), poste::GetSolde(), poste::GetSoldeDetail(), ImpHtml(), IsFicheOfJrn(), ListJrn(), MenuJrn(), new_fiche(), PosteForm(), ShowDevise(), ShowDossier(), ShowMenuComptaForm(), ShowMenuFiche(), ShowMenuJrnUser(), ShowPeriode(), TransferCSV(), and ViewFiche().

$Max2 = pg_NumRows($Res2)
 

Definition at line 434 of file setup.php.

$MaxDossier = pg_NumRows($Resdossier)
 

Definition at line 392 of file setup.php.

$Res = CountSql($cn,$sql)
 

Definition at line 253 of file setup.php.

$Res2 = ExecSql($db,'select coalesce(max(jr_grpt_id),1) as l from jrn')
 

Definition at line 433 of file setup.php.

Referenced by Centralise(), CheckJrn(), TransferCSV(), and Customer::VatListing().

$Resdossier = ExecSql($cn,"select dos_id, dos_name from ac_dossier")
 

Definition at line 391 of file setup.php.

$sql = "select lanname from pg_language where lanname='plpgsql'"
 

Definition at line 252 of file setup.php.

else print Connect to database success< br >
 

Definition at line 385 of file setup.php.