diff --git a/htdocs/core/db/Database.interface.php b/htdocs/core/db/Database.interface.php index e3f6f47fb4d..ab38cdf378c 100644 --- a/htdocs/core/db/Database.interface.php +++ b/htdocs/core/db/Database.interface.php @@ -4,7 +4,7 @@ * Copyright (C) 2004-2011 Laurent Destailleur * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2014 Raphaël Doursenaud + * Copyright (C) 2014-2015 Raphaël Doursenaud * * 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 diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php index 0aae168be79..6a7c5276025 100644 --- a/htdocs/core/db/DoliDB.class.php +++ b/htdocs/core/db/DoliDB.class.php @@ -1,6 +1,6 @@ + * Copyright (C) 2013-2015 Raphaël Doursenaud * Copyright (C) 2014-2015 Laurent Destailleur * * 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) diff --git a/htdocs/core/db/mssql.class.php b/htdocs/core/db/mssql.class.php index c3b2b93a7ee..0aed5a6ee11 100644 --- a/htdocs/core/db/mssql.class.php +++ b/htdocs/core/db/mssql.class.php @@ -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; diff --git a/htdocs/core/db/mysql.class.php b/htdocs/core/db/mysql.class.php index e4efaa50b97..5f913b38ae0 100644 --- a/htdocs/core/db/mysql.class.php +++ b/htdocs/core/db/mysql.class.php @@ -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; diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index 77d484b92bf..0a46e70e2ba 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -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; diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index c276b132eb0..d4866daa1c2 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -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; diff --git a/htdocs/core/db/sqlite.class.php b/htdocs/core/db/sqlite.class.php index c1819151a35..fca8dbeafee 100644 --- a/htdocs/core/db/sqlite.class.php +++ b/htdocs/core/db/sqlite.class.php @@ -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; } diff --git a/htdocs/core/db/sqlite3.class.php b/htdocs/core/db/sqlite3.class.php index 1024dafd0cc..0efc201a696 100644 --- a/htdocs/core/db/sqlite3.class.php +++ b/htdocs/core/db/sqlite3.class.php @@ -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; diff --git a/htdocs/install/check.php b/htdocs/install/check.php index 15ba736acd5..4149691302e 100644 --- a/htdocs/install/check.php +++ b/htdocs/install/check.php @@ -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; } } } diff --git a/htdocs/install/etape1.php b/htdocs/install/etape1.php index 32f85a0860d..5817af81e9b 100644 --- a/htdocs/install/etape1.php +++ b/htdocs/install/etape1.php @@ -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 ""; @@ -648,7 +648,7 @@ if (! $error && $db->connected && $action == "set") print ""; // 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 ""; diff --git a/htdocs/install/etape2.php b/htdocs/install/etape2.php index d803a622a3b..8de44812222 100644 --- a/htdocs/install/etape2.php +++ b/htdocs/install/etape2.php @@ -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 ""; print $langs->trans("ServerConnection")." : ".$conf->db->host.'Ok'; @@ -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); } diff --git a/htdocs/install/etape4.php b/htdocs/install/etape4.php index 54639505701..fc4f47f4611 100644 --- a/htdocs/install/etape4.php +++ b/htdocs/install/etape4.php @@ -71,7 +71,7 @@ print ''; $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 ''; diff --git a/htdocs/install/etape5.php b/htdocs/install/etape5.php index d6a5d086b31..da871508176 100644 --- a/htdocs/install/etape5.php +++ b/htdocs/install/etape5.php @@ -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); diff --git a/htdocs/install/repair.php b/htdocs/install/repair.php index a8bbfdd09af..786a8efb430 100644 --- a/htdocs/install/repair.php +++ b/htdocs/install/repair.php @@ -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 '"; @@ -117,7 +117,7 @@ else if ($ok) { - if($db->database_selected == 1) + if($db->database_selected) { print '"; diff --git a/htdocs/install/upgrade.php b/htdocs/install/upgrade.php index c001a771f06..9c2832f3623 100644 --- a/htdocs/install/upgrade.php +++ b/htdocs/install/upgrade.php @@ -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 '\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 '\n"; diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index 8d63f02ddc8..091218513af 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -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 ''; 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); }
'.$langs->trans("DolibarrAdminLogin").' :'; print '
'; print $langs->trans("ServerConnection")." : $dolibarr_main_db_host".$langs->trans("OK")."
'; print $langs->trans("DatabaseConnection")." : ".$dolibarr_main_db_name."".$langs->trans("OK")."
'; print $langs->trans("ServerConnection")." : $dolibarr_main_db_host".$langs->trans("OK")."
'; print $langs->trans("DatabaseConnection")." : ".$dolibarr_main_db_name."".$langs->trans("OK")."
'.$langs->trans("ErrorFailedToConnectToDatabase",$conf->db->name).''.$langs->trans('Error').'