Better type hinting for DoliDB

This commit is contained in:
Raphaël Doursenaud 2015-05-12 19:01:01 +02:00
parent ccd14c8305
commit 27d52cf2b0
16 changed files with 145 additions and 158 deletions

View File

@ -4,7 +4,7 @@
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2014-2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -111,13 +111,6 @@ interface Database
*/
function error();
/**
* Return label of manager
*
* @return string Label
*/
function getLabel();
/**
* List tables into a database
*
@ -141,7 +134,7 @@ interface Database
* @param string $sortorder Sort order
* @return string String to provide syntax of a sort sql string
*/
function order($sortfield = 0, $sortorder = 0);
function order($sortfield = null, $sortorder = null);
/**
* Decrypt sensitive data in database
@ -382,15 +375,15 @@ interface Database
);
/**
* Convert (by PHP) a PHP server TZ string date into a Timestamps date (GMT if gm=true)
* 19700101020000 -> 3600 with TZ+1 and gmt=0
* 19700101020000 -> 7200 whaterver is TZ if gmt=1
*
* Convert (by PHP) a PHP server TZ string date into a Timestamps date (GMT if gm=true)
* 19700101020000 -> 3600 with TZ+1 and gmt=0
* 19700101020000 -> 7200 whaterver is TZ if gmt=1
*
* @param string $string Date in a string (YYYYMMDDHHMMSS, YYYYMMDD, YYYY-MM-DD HH:MM:SS)
* @param int $gm 1=Input informations are GMT values, otherwise local to server TZ
* @param bool $gm 1=Input informations are GMT values, otherwise local to server TZ
* @return int|string Date TMS or ''
*/
function jdate($string, $gm=false);
*/
function jdate($string, $gm=false);
/**
* Encrypt sensitive data in database

View File

@ -1,6 +1,6 @@
<?php
/*
* Copyright (C) 2013-2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2013-2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2014-2015 Laurent Destailleur <eldy@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
@ -29,41 +29,43 @@ require_once DOL_DOCUMENT_ROOT .'/core/db/Database.interface.php';
*/
abstract class DoliDB implements Database
{
//! Database handler
public $db;
//! Database type
public $type;
//! Charset used to force charset when creating database
public $forcecharset='utf8';
//! Collate used to force collate when creating database
public $forcecollate='utf8_general_ci';
//! Resultset of last query
private $_results;
//! 1 if connected, else 0
public $connected;
//! 1 if database selected, else 0
public $database_selected;
//! Selected database name
public $database_name;
//! Database username
public $database_user;
//! Database host
public $database_host;
//! Database port
public $database_port;
//! >=1 if a transaction is opened, 0 otherwise
public $transaction_opened;
//! Last successful query
public $lastquery;
//! Last failed query
public $lastqueryerror;
//! Last error message
public $lasterror;
//! Last error number
public $lasterrno;
/** @var resource Database handler */
public $db;
/** @var string Database type */
public $type;
/** @var string Charset used to force charset when creating database */
public $forcecharset='utf8';
/** @var string Collate used to force collate when creating database */
public $forcecollate='utf8_general_ci';
/** @var resource Resultset of last query */
private $_results;
/** @var bool true if connected, else false */
public $connected;
/** @var bool true if database selected, else false */
public $database_selected;
/** @var string Selected database name */
public $database_name;
/** @var string Database username */
public $database_user;
/** @var string Database host */
public $database_host;
/** @var int Database port */
public $database_port;
/** @var int >=1 if a transaction is opened, 0 otherwise */
public $transaction_opened;
/** @var string Last successful query */
public $lastquery;
/** @ar string Last failed query */
public $lastqueryerror;
/** @var string Last error message */
public $lasterror;
/** @var int Last error number */
public $lasterrno;
public $ok;
public $error;
/** @var bool Status */
public $ok;
/** @var string */
public $error;
/**
* Format a SQL IF
@ -205,16 +207,6 @@ abstract class DoliDB implements Database
return preg_split("/[\.,-]/",$this->getVersion());
}
/**
* Return label of manager
*
* @return string Label
*/
function getLabel()
{
return $this->label;
}
/**
* Return last request executed with query()
*
@ -232,9 +224,9 @@ abstract class DoliDB implements Database
* @param string $sortorder Sort order
* @return string String to provide syntax of a sort sql string
*/
function order($sortfield=0,$sortorder=0)
function order($sortfield=null,$sortorder=null)
{
if ($sortfield)
if (isset($sortfield))
{
$return='';
$fields=explode(',',$sortfield);
@ -244,7 +236,9 @@ abstract class DoliDB implements Database
else $return.=',';
$return.=preg_replace('/[^0-9a-z_\.]/i','',$val);
if ($sortorder) $return.=' '.preg_replace('/[^0-9a-z]/i','',$sortorder);
if (isset($sortorder)) {
$return.=' '.preg_replace('/[^0-9a-z]/i','',$sortorder);
}
}
return $return;
}
@ -270,7 +264,7 @@ abstract class DoliDB implements Database
* 19700101020000 -> 7200 whaterver is TZ if gmt=1
*
* @param string $string Date in a string (YYYYMMDDHHMMSS, YYYYMMDD, YYYY-MM-DD HH:MM:SS)
* @param int $gm 1=Input informations are GMT values, otherwise local to server TZ
* @param bool $gm 1=Input informations are GMT values, otherwise local to server TZ
* @return int|string Date TMS or ''
*/
function jdate($string, $gm=false)

View File

@ -66,8 +66,8 @@ class DoliDBMssql extends DoliDB
if (! function_exists("mssql_connect"))
{
$this->connected = 0;
$this->ok = 0;
$this->connected = false;
$this->ok = false;
$this->error="Mssql PHP functions for using MSSql driver are not available in this version of PHP";
dol_syslog(get_class($this)."::DoliDBMssql : MSsql PHP functions for using MSsql driver are not available in this version of PHP",LOG_ERR);
return $this->ok;
@ -75,8 +75,8 @@ class DoliDBMssql extends DoliDB
if (! $host)
{
$this->connected = 0;
$this->ok = 0;
$this->connected = false;
$this->ok = false;
$this->error=$langs->trans("ErrorWrongHostParameter");
dol_syslog(get_class($this)."::DoliDBMssql : Erreur Connect, wrong host parameters",LOG_ERR);
return $this->ok;
@ -88,14 +88,14 @@ class DoliDBMssql extends DoliDB
{
// Si client connecte avec charset different de celui de la base Dolibarr
// (La base Dolibarr a ete forcee en this->forcecharset a l'install)
$this->connected = 1;
$this->ok = 1;
$this->connected = true;
$this->ok = true;
}
else
{
// host, login ou password incorrect
$this->connected = 0;
$this->ok = 0;
$this->connected = false;
$this->ok = false;
$this->error=mssql_get_last_message();
dol_syslog(get_class($this)."::DoliDBMssql : Erreur Connect mssql_get_last_message=".$this->error,LOG_ERR);
}
@ -105,15 +105,15 @@ class DoliDBMssql extends DoliDB
{
if ($this->select_db($name))
{
$this->database_selected = 1;
$this->database_selected = true;
$this->database_name = $name;
$this->ok = 1;
$this->ok = true;
}
else
{
$this->database_selected = 0;
$this->database_selected = false;
$this->database_name = '';
$this->ok = 0;
$this->ok = false;
$this->error=$this->error();
dol_syslog(get_class($this)."::DoliDBMssql : Erreur Select_db ".$this->error,LOG_ERR);
}
@ -121,7 +121,7 @@ class DoliDBMssql extends DoliDB
else
{
// Pas de selection de base demandee, ok ou ko
$this->database_selected = 0;
$this->database_selected = false;
}
return $this->ok;
@ -220,7 +220,7 @@ class DoliDBMssql extends DoliDB
if ($this->db)
{
if ($this->transaction_opened > 0) dol_syslog(get_class($this)."::close Closing a connection with an opened transaction depth=".$this->transaction_opened,LOG_ERR);
$this->connected=0;
$this->connected=false;
return mssql_close($this->db);
}
return false;

View File

@ -69,8 +69,8 @@ class DoliDBMysql extends DoliDB
if (! function_exists("mysql_connect"))
{
$this->connected = 0;
$this->ok = 0;
$this->connected = false;
$this->ok = false;
$this->error="Mysql PHP functions for using MySql driver are not available in this version of PHP. Try to use another driver.";
dol_syslog(get_class($this)."::DoliDBMysql : Mysql PHP functions for using Mysql driver are not available in this version of PHP. Try to use another driver.",LOG_ERR);
return $this->ok;
@ -78,8 +78,8 @@ class DoliDBMysql extends DoliDB
if (! $host)
{
$this->connected = 0;
$this->ok = 0;
$this->connected = false;
$this->ok = false;
$this->error=$langs->trans("ErrorWrongHostParameter");
dol_syslog(get_class($this)."::DoliDBMysql : Erreur Connect, wrong host parameters",LOG_ERR);
return $this->ok;
@ -89,14 +89,14 @@ class DoliDBMysql extends DoliDB
$this->db = $this->connect($host, $user, $pass, $name, $port);
if ($this->db)
{
$this->connected = 1;
$this->ok = 1;
$this->connected = true;
$this->ok = true;
}
else
{
// host, login ou password incorrect
$this->connected = 0;
$this->ok = 0;
$this->connected = false;
$this->ok = false;
$this->error=mysql_error();
dol_syslog(get_class($this)."::DoliDBMysql : Erreur Connect mysql_error=".$this->error,LOG_ERR);
}
@ -106,9 +106,9 @@ class DoliDBMysql extends DoliDB
{
if ($this->select_db($name))
{
$this->database_selected = 1;
$this->database_selected = true;
$this->database_name = $name;
$this->ok = 1;
$this->ok = true;
// If client connected with different charset than Dolibarr HTML output
$clientmustbe='';
@ -122,9 +122,9 @@ class DoliDBMysql extends DoliDB
}
else
{
$this->database_selected = 0;
$this->database_selected = false;
$this->database_name = '';
$this->ok = 0;
$this->ok = false;
$this->error=$this->error();
dol_syslog(get_class($this)."::DoliDBMysql : Erreur Select_db ".$this->error,LOG_ERR);
}
@ -132,7 +132,7 @@ class DoliDBMysql extends DoliDB
else
{
// Pas de selection de base demandee, ok ou ko
$this->database_selected = 0;
$this->database_selected = false;
if ($this->connected)
{
@ -234,7 +234,7 @@ class DoliDBMysql extends DoliDB
if ($this->db)
{
if ($this->transaction_opened > 0) dol_syslog(get_class($this)."::close Closing a connection with an opened transaction depth=".$this->transaction_opened,LOG_ERR);
$this->connected=0;
$this->connected=false;
return mysql_close($this->db);
}
return false;

View File

@ -69,8 +69,8 @@ class DoliDBMysqli extends DoliDB
if (! function_exists("mysqli_connect"))
{
$this->connected = 0;
$this->ok = 0;
$this->connected = false;
$this->ok = false;
$this->error="Mysqli PHP functions for using Mysqli driver are not available in this version of PHP. Try to use another driver.";
dol_syslog(get_class($this)."::DoliDBMysqli : Mysqli PHP functions for using Mysqli driver are not available in this version of PHP. Try to use another driver.",LOG_ERR);
return $this->ok;
@ -78,8 +78,8 @@ class DoliDBMysqli extends DoliDB
if (! $host)
{
$this->connected = 0;
$this->ok = 0;
$this->connected = false;
$this->ok = false;
$this->error=$langs->trans("ErrorWrongHostParameter");
dol_syslog(get_class($this)."::DoliDBMysqli : Erreur Connect, wrong host parameters",LOG_ERR);
return $this->ok;
@ -91,14 +91,14 @@ class DoliDBMysqli extends DoliDB
if ($this->db)
{
$this->connected = 1;
$this->ok = 1;
$this->connected = true;
$this->ok = true;
}
else
{
// host, login ou password incorrect
$this->connected = 0;
$this->ok = 0;
$this->connected = false;
$this->ok = false;
$this->error=mysqli_connect_error();
dol_syslog(get_class($this)."::DoliDBMysqli : Erreur Connect mysqli_connect_error=".$this->error,LOG_ERR);
}
@ -108,9 +108,9 @@ class DoliDBMysqli extends DoliDB
{
if ($this->select_db($name))
{
$this->database_selected = 1;
$this->database_selected = true;
$this->database_name = $name;
$this->ok = 1;
$this->ok = true;
// If client connected with different charset than Dolibarr HTML output
$clientmustbe='';
@ -124,9 +124,9 @@ class DoliDBMysqli extends DoliDB
}
else
{
$this->database_selected = 0;
$this->database_selected = false;
$this->database_name = '';
$this->ok = 0;
$this->ok = false;
$this->error=$this->error();
dol_syslog(get_class($this)."::DoliDBMysqli : Erreur Select_db ".$this->error,LOG_ERR);
}
@ -134,7 +134,7 @@ class DoliDBMysqli extends DoliDB
else
{
// Pas de selection de base demandee, ok ou ko
$this->database_selected = 0;
$this->database_selected = false;
if ($this->connected)
{
@ -238,7 +238,7 @@ class DoliDBMysqli extends DoliDB
if ($this->db)
{
if ($this->transaction_opened > 0) dol_syslog(get_class($this)."::close Closing a connection with an opened transaction depth=".$this->transaction_opened,LOG_ERR);
$this->connected=0;
$this->connected=false;
return mysqli_close($this->db);
}
return false;

View File

@ -80,8 +80,8 @@ class DoliDBPgsql extends DoliDB
if (! function_exists("pg_connect"))
{
$this->connected = 0;
$this->ok = 0;
$this->connected = false;
$this->ok = false;
$this->error="Pgsql PHP functions are not available in this version of PHP";
dol_syslog(get_class($this)."::DoliDBPgsql : Pgsql PHP functions are not available in this version of PHP",LOG_ERR);
return $this->ok;
@ -89,8 +89,8 @@ class DoliDBPgsql extends DoliDB
if (! $host)
{
$this->connected = 0;
$this->ok = 0;
$this->connected = false;
$this->ok = false;
$this->error=$langs->trans("ErrorWrongHostParameter");
dol_syslog(get_class($this)."::DoliDBPgsql : Erreur Connect, wrong host parameters",LOG_ERR);
return $this->ok;
@ -102,14 +102,14 @@ class DoliDBPgsql extends DoliDB
if ($this->db)
{
$this->connected = 1;
$this->ok = 1;
$this->connected = true;
$this->ok = true;
}
else
{
// host, login ou password incorrect
$this->connected = 0;
$this->ok = 0;
$this->connected = false;
$this->ok = false;
$this->error='Host, login or password incorrect';
dol_syslog(get_class($this)."::DoliDBPgsql : Erreur Connect ".$this->error,LOG_ERR);
}
@ -119,15 +119,15 @@ class DoliDBPgsql extends DoliDB
{
if ($this->select_db($name))
{
$this->database_selected = 1;
$this->database_selected = true;
$this->database_name = $name;
$this->ok = 1;
$this->ok = true;
}
else
{
$this->database_selected = 0;
$this->database_selected = false;
$this->database_name = '';
$this->ok = 0;
$this->ok = false;
$this->error=$this->error();
dol_syslog(get_class($this)."::DoliDBPgsql : Erreur Select_db ".$this->error,LOG_ERR);
}
@ -135,7 +135,7 @@ class DoliDBPgsql extends DoliDB
else
{
// Pas de selection de base demandee, ok ou ko
$this->database_selected = 0;
$this->database_selected = false;
}
return $this->ok;
@ -451,7 +451,7 @@ class DoliDBPgsql extends DoliDB
if ($this->db)
{
if ($this->transaction_opened > 0) dol_syslog(get_class($this)."::close Closing a connection with an opened transaction depth=".$this->transaction_opened,LOG_ERR);
$this->connected=0;
$this->connected=false;
return pg_close($this->db);
}
return false;

View File

@ -70,8 +70,8 @@ class DoliDBSqlite extends DoliDB
/*if (! function_exists("sqlite_query"))
{
$this->connected = 0;
$this->ok = 0;
$this->connected = false;
$this->ok = false;
$this->error="Sqlite PHP functions for using Sqlite driver are not available in this version of PHP. Try to use another driver.";
dol_syslog(get_class($this)."::DoliDBSqlite : Sqlite PHP functions for using Sqlite driver are not available in this version of PHP. Try to use another driver.",LOG_ERR);
return $this->ok;
@ -79,8 +79,8 @@ class DoliDBSqlite extends DoliDB
/*if (! $host)
{
$this->connected = 0;
$this->ok = 0;
$this->connected = false;
$this->ok = false;
$this->error=$langs->trans("ErrorWrongHostParameter");
dol_syslog(get_class($this)."::DoliDBSqlite : Erreur Connect, wrong host parameters",LOG_ERR);
return $this->ok;
@ -92,9 +92,9 @@ class DoliDBSqlite extends DoliDB
if ($this->db)
{
$this->connected = 1;
$this->ok = 1;
$this->database_selected = 1;
$this->connected = true;
$this->ok = true;
$this->database_selected = true;
$this->database_name = $name;
$this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
@ -102,9 +102,9 @@ class DoliDBSqlite extends DoliDB
else
{
// host, login ou password incorrect
$this->connected = 0;
$this->ok = 0;
$this->database_selected = 0;
$this->connected = false;
$this->ok = false;
$this->database_selected = false;
$this->database_name = '';
//$this->error=sqlite_connect_error();
dol_syslog(get_class($this)."::DoliDBSqlite : Erreur Connect ".$this->error,LOG_ERR);
@ -360,7 +360,7 @@ class DoliDBSqlite extends DoliDB
if ($this->db)
{
if ($this->transaction_opened > 0) dol_syslog(get_class($this)."::close Closing a connection with an opened transaction depth=".$this->transaction_opened,LOG_ERR);
$this->connected=0;
$this->connected=false;
$this->db=null; // Clean this->db
return true;
}

View File

@ -74,8 +74,8 @@ class DoliDBSqlite3 extends DoliDB
/*if (! function_exists("sqlite_query"))
{
$this->connected = 0;
$this->ok = 0;
$this->connected = false;
$this->ok = false;
$this->error="Sqlite PHP functions for using Sqlite driver are not available in this version of PHP. Try to use another driver.";
dol_syslog(get_class($this)."::DoliDBSqlite3 : Sqlite PHP functions for using Sqlite driver are not available in this version of PHP. Try to use another driver.",LOG_ERR);
return $this->ok;
@ -83,8 +83,8 @@ class DoliDBSqlite3 extends DoliDB
/*if (! $host)
{
$this->connected = 0;
$this->ok = 0;
$this->connected = false;
$this->ok = false;
$this->error=$langs->trans("ErrorWrongHostParameter");
dol_syslog(get_class($this)."::DoliDBSqlite3 : Erreur Connect, wrong host parameters",LOG_ERR);
return $this->ok;
@ -96,9 +96,9 @@ class DoliDBSqlite3 extends DoliDB
if ($this->db)
{
$this->connected = 1;
$this->ok = 1;
$this->database_selected = 1;
$this->connected = true;
$this->ok = true;
$this->database_selected = true;
$this->database_name = $name;
$this->addCustomFunction('IF');
@ -114,9 +114,9 @@ class DoliDBSqlite3 extends DoliDB
else
{
// host, login ou password incorrect
$this->connected = 0;
$this->ok = 0;
$this->database_selected = 0;
$this->connected = false;
$this->ok = false;
$this->database_selected = false;
$this->database_name = '';
//$this->error=sqlite_connect_error();
dol_syslog(get_class($this)."::DoliDBSqlite3 : Error Connect ".$this->error,LOG_ERR);
@ -380,7 +380,7 @@ class DoliDBSqlite3 extends DoliDB
if ($this->db)
{
if ($this->transaction_opened > 0) dol_syslog(get_class($this)."::close Closing a connection with an opened transaction depth=".$this->transaction_opened,LOG_ERR);
$this->connected=0;
$this->connected=false;
$this->db->close();
$this->db=null; // Clean this->db
return true;

View File

@ -296,9 +296,9 @@ else
$conf->db->user = $dolibarr_main_db_user;
$conf->db->pass = $dolibarr_main_db_pass;
$db=getDoliDBInstance($conf->db->type,$conf->db->host,$conf->db->user,$conf->db->pass,$conf->db->name,$conf->db->port);
if ($db->connected == 1 && $db->database_selected == 1)
if ($db->connected && $db->database_selected)
{
$ok=1;
$ok=true;
}
}
}

View File

@ -637,7 +637,7 @@ if (! $error && $db->connected && $action == "set")
$db=getDoliDBInstance($conf->db->type,$conf->db->host,$conf->db->user,$conf->db->pass,$conf->db->name,$conf->db->port);
if ($db->connected == 1)
if ($db->connected)
{
dolibarr_install_syslog("etape1: connexion to server by user ".$conf->db->user." is ok", LOG_DEBUG);
print "<tr><td>";
@ -648,7 +648,7 @@ if (! $error && $db->connected && $action == "set")
print "</td></tr>";
// si acces serveur ok et acces base ok, tout est ok, on ne va pas plus loin, on a meme pas utilise le compte root.
if ($db->database_selected == 1)
if ($db->database_selected)
{
dolibarr_install_syslog("etape1: connexion to database : ".$conf->db->name.", by user : ".$conf->db->user." is ok", LOG_DEBUG);
print "<tr><td>";

View File

@ -88,7 +88,7 @@ if ($action == "set")
$db=getDoliDBInstance($conf->db->type,$conf->db->host,$conf->db->user,$conf->db->pass,$conf->db->name,$conf->db->port);
if ($db->connected == 1)
if ($db->connected)
{
print "<tr><td>";
print $langs->trans("ServerConnection")." : ".$conf->db->host.'</td><td><img src="../theme/eldy/img/tick.png" alt="Ok"></td></tr>';
@ -101,7 +101,7 @@ if ($action == "set")
if ($ok)
{
if($db->database_selected == 1)
if($db->database_selected)
{
dolibarr_install_syslog("etape2: Connexion successful to database : ".$conf->db->name);
}

View File

@ -71,7 +71,7 @@ print '<table cellspacing="0" cellpadding="2" width="100%">';
$db=getDoliDBInstance($conf->db->type,$conf->db->host,$conf->db->user,$conf->db->pass,$conf->db->name,$conf->db->port);
if ($db->ok == 1)
if ($db->ok)
{
print '<tr><td>'.$langs->trans("DolibarrAdminLogin").' :</td><td>';
print '<input name="login" type="text" value="'.(! empty($_GET["login"])?$_GET["login"]:(isset($force_install_dolibarrlogin)?$force_install_dolibarrlogin:'')).'"></td></tr>';

View File

@ -159,7 +159,7 @@ if ($action == "set" || empty($action) || preg_match('/upgrade/i',$action))
$result=$objMod->init();
if (! $result) print 'ERROR in activating module file='.$file;
if ($db->connected == 1)
if ($db->connected)
{
$conf->setValues($db);
@ -255,7 +255,7 @@ if ($action == "set" || empty($action) || preg_match('/upgrade/i',$action))
// If upgrade
elseif (empty($action) || preg_match('/upgrade/i',$action))
{
if ($db->connected == 1)
if ($db->connected)
{
$conf->setValues($db);

View File

@ -101,7 +101,7 @@ $conf->db->dolibarr_main_db_cryptkey = isset($dolibarr_main_db_cryptkey)?$doliba
$db=getDoliDBInstance($conf->db->type,$conf->db->host,$conf->db->user,$conf->db->pass,$conf->db->name,$conf->db->port);
if ($db->connected == 1)
if ($db->connected)
{
print '<tr><td class="nowrap">';
print $langs->trans("ServerConnection")." : $dolibarr_main_db_host</td><td align=\"right\">".$langs->trans("OK")."</td></tr>";
@ -117,7 +117,7 @@ else
if ($ok)
{
if($db->database_selected == 1)
if($db->database_selected)
{
print '<tr><td class="nowrap">';
print $langs->trans("DatabaseConnection")." : ".$dolibarr_main_db_name."</td><td align=\"right\">".$langs->trans("OK")."</td></tr>";

View File

@ -141,7 +141,7 @@ if (! GETPOST("action") || preg_match('/upgrade/i',GETPOST('action')))
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($db);
if ($db->connected == 1)
if ($db->connected)
{
print '<tr><td class="nowrap">';
print $langs->trans("ServerConnection")." : $dolibarr_main_db_host</td><td align=\"right\">".$langs->trans("OK")."</td></tr>\n";
@ -157,7 +157,7 @@ if (! GETPOST("action") || preg_match('/upgrade/i',GETPOST('action')))
if ($ok)
{
if($db->database_selected == 1)
if($db->database_selected)
{
print '<tr><td class="nowrap">';
print $langs->trans("DatabaseConnection")." : ".$dolibarr_main_db_name."</td><td align=\"right\">".$langs->trans("OK")."</td></tr>\n";

View File

@ -134,7 +134,7 @@ if (! GETPOST("action") || preg_match('/upgrade/i',GETPOST('action')))
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($db);
if ($db->connected != 1)
if (!$db->connected)
{
print '<tr><td colspan="4">'.$langs->trans("ErrorFailedToConnectToDatabase",$conf->db->name).'</td><td align="right">'.$langs->trans('Error').'</td></tr>';
dolibarr_install_syslog('upgrade2: Failed to connect to database : '.$conf->db->name.' on '.$conf->db->host.' for user '.$conf->db->user, LOG_ERR);
@ -143,7 +143,7 @@ if (! GETPOST("action") || preg_match('/upgrade/i',GETPOST('action')))
if (! $error)
{
if($db->database_selected == 1)
if($db->database_selected)
{
dolibarr_install_syslog('upgrade2: Database connection successfull : '.$dolibarr_main_db_name);
}