Fix: error management of pgconnect
Doxygen
This commit is contained in:
parent
f8fbc192d7
commit
427d099e87
@ -795,10 +795,11 @@ class DoliDBMssql
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief List tables into a database.
|
||||
* \param database Name of database
|
||||
* \param table Filter on some tables
|
||||
* \return array Array list of tables
|
||||
* List tables into a database
|
||||
*
|
||||
* @param string $database Name of database
|
||||
* @param string $table Nmae of table filter ('xxx%')
|
||||
* @return resource Resource
|
||||
*/
|
||||
function DDLListTables($database,$table='')
|
||||
{
|
||||
@ -884,11 +885,12 @@ class DoliDBMssql
|
||||
}
|
||||
|
||||
/**
|
||||
\brief decrit une table dans une database.
|
||||
\param table Nom de la table
|
||||
\param field Optionnel : Nom du champ si l'on veut la desc d'un champ
|
||||
\return resource
|
||||
*/
|
||||
* Return a pointer of line with description of a table or field
|
||||
*
|
||||
* @param string $table Name of table
|
||||
* @param string $field Optionnel : Name of field if we want description of field
|
||||
* @return resource Resource
|
||||
*/
|
||||
function DDLDescTable($table,$field="")
|
||||
{
|
||||
$sql="DESC ".$table." ".$field;
|
||||
@ -899,12 +901,13 @@ class DoliDBMssql
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Insert a new field in table
|
||||
* \param table Nom de la table
|
||||
* \param field_name Nom du champ a inserer
|
||||
* \param field_desc Tableau associatif de description du champ a inserer[nom du parametre][valeur du parametre]
|
||||
* \param field_position Optionnel ex.: "after champtruc"
|
||||
* \return int <0 si KO, >0 si OK
|
||||
* Create a new field into table
|
||||
*
|
||||
* @param string $table Name of table
|
||||
* @param string $field_name Name of field to add
|
||||
* @param string $field_desc Tableau associatif de description du champ a inserer[nom du parametre][valeur du parametre]
|
||||
* @param string $field_position Optionnel ex.: "after champtruc"
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function DDLAddField($table,$field_name,$field_desc,$field_position="")
|
||||
{
|
||||
@ -935,10 +938,11 @@ class DoliDBMssql
|
||||
|
||||
/**
|
||||
* Update format of a field into a table
|
||||
* @param table Name of table
|
||||
* @param field_name Name of field to modify
|
||||
* @param field_desc Array with description of field format
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*
|
||||
* @param string $table Name of table
|
||||
* @param string $field_name Name of field to modify
|
||||
* @param string $field_desc Array with description of field format
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function DDLUpdateField($table,$field_name,$field_desc)
|
||||
{
|
||||
@ -954,10 +958,11 @@ class DoliDBMssql
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Drop a field in table
|
||||
* \param table Nom de la table
|
||||
* \param field_name Nom du champ a inserer
|
||||
* \return int <0 si KO, >0 si OK
|
||||
* Drop a field from table
|
||||
*
|
||||
* @param string $table Name of table
|
||||
* @param string $field_name Name of field to drop
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function DDLDropField($table,$field_name)
|
||||
{
|
||||
@ -972,7 +977,13 @@ class DoliDBMssql
|
||||
}
|
||||
|
||||
|
||||
function getDefaultCharacterSetDatabase(){
|
||||
/**
|
||||
* Return charset used to store data in database
|
||||
*
|
||||
* @return string Charset
|
||||
*/
|
||||
function getDefaultCharacterSetDatabase()
|
||||
{
|
||||
/*
|
||||
$resql=$this->query('SHOW VARIABLES LIKE \'character_set_database\'');
|
||||
if (!$resql)
|
||||
@ -985,7 +996,13 @@ class DoliDBMssql
|
||||
return '';
|
||||
}
|
||||
|
||||
function getListOfCharacterSet(){
|
||||
/**
|
||||
* Return list of available charset that can be used to store data in database
|
||||
*
|
||||
* @return array List of Charset
|
||||
*/
|
||||
function getListOfCharacterSet()
|
||||
{
|
||||
/*
|
||||
$resql=$this->query('SHOW CHARSET');
|
||||
$liste = array();
|
||||
@ -1007,6 +1024,11 @@ class DoliDBMssql
|
||||
return ''; // attente debuggage
|
||||
}
|
||||
|
||||
/**
|
||||
* Return collation used in database
|
||||
*
|
||||
* @return string Collation value
|
||||
*/
|
||||
function getDefaultCollationDatabase()
|
||||
{
|
||||
$resql=$this->query("SELECT SERVERPROPERTY('collation')");
|
||||
@ -1018,6 +1040,11 @@ class DoliDBMssql
|
||||
return $liste['computed'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Return list of available collation that can be used for database
|
||||
*
|
||||
* @return array Liste of Collation
|
||||
*/
|
||||
function getListOfCollation()
|
||||
{
|
||||
/*
|
||||
@ -1040,8 +1067,9 @@ class DoliDBMssql
|
||||
return ''; // attente debugage
|
||||
}
|
||||
|
||||
/*
|
||||
* Return full path of dump program
|
||||
/**
|
||||
* Return full path of dump program
|
||||
*
|
||||
* @return string Full path of dump program
|
||||
*/
|
||||
function getPathOfDump()
|
||||
@ -1050,10 +1078,11 @@ class DoliDBMssql
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Return full path of restore program
|
||||
* @return string Full path of restore program
|
||||
*/
|
||||
/**
|
||||
* Return full path of restore program
|
||||
*
|
||||
* @return string Full path of restore program
|
||||
*/
|
||||
function getPathOfRestore()
|
||||
{
|
||||
|
||||
|
||||
@ -802,10 +802,11 @@ class DoliDBMysql
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief List tables into a database.
|
||||
* \param database Name of database
|
||||
* \param table Filter on some tables
|
||||
* \return array Array list of tables
|
||||
* List tables into a database
|
||||
*
|
||||
* @param string $database Name of database
|
||||
* @param string $table Nmae of table filter ('xxx%')
|
||||
* @return resource Resource
|
||||
*/
|
||||
function DDLListTables($database, $table='')
|
||||
{
|
||||
@ -824,9 +825,10 @@ class DoliDBMysql
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Liste les informations des champs d'une table.
|
||||
* \param table Nom de la table
|
||||
* \return array Tableau des informations des champs de la table
|
||||
* List information of columns into a table.
|
||||
*
|
||||
* @param string $table Name of table
|
||||
* @return array Tableau des informations des champs de la table
|
||||
*/
|
||||
function DDLInfoTable($table)
|
||||
{
|
||||
@ -921,10 +923,11 @@ class DoliDBMysql
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a pointer on fields describing table
|
||||
* @param table Nom de la table
|
||||
* @param field Optionnel : Nom du champ si l'on veut la desc d'un champ
|
||||
* @return resource
|
||||
* Return a pointer of line with description of a table or field
|
||||
*
|
||||
* @param string $table Name of table
|
||||
* @param string $field Optionnel : Name of field if we want description of field
|
||||
* @return resource Resource
|
||||
*/
|
||||
function DDLDescTable($table,$field="")
|
||||
{
|
||||
@ -936,12 +939,13 @@ class DoliDBMysql
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert a new field in table
|
||||
* @param table Table name
|
||||
* @param field_name Name of field
|
||||
* @param field_desc Array with properties describing new field
|
||||
* @param field_position Optionnal ie.: "after fielddummy"
|
||||
* @return int <0 if KO, >0 if OK
|
||||
* Create a new field into table
|
||||
*
|
||||
* @param string $table Name of table
|
||||
* @param string $field_name Name of field to add
|
||||
* @param string $field_desc Tableau associatif de description du champ a inserer[nom du parametre][valeur du parametre]
|
||||
* @param string $field_position Optionnel ex.: "after champtruc"
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function DDLAddField($table,$field_name,$field_desc,$field_position="")
|
||||
{
|
||||
@ -982,10 +986,11 @@ class DoliDBMysql
|
||||
|
||||
/**
|
||||
* Update format of a field into a table
|
||||
* @param table Name of table
|
||||
* @param field_name Name of field to modify
|
||||
* @param field_desc Array with description of field format
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*
|
||||
* @param string $table Name of table
|
||||
* @param string $field_name Name of field to modify
|
||||
* @param string $field_desc Array with description of field format
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function DDLUpdateField($table,$field_name,$field_desc)
|
||||
{
|
||||
@ -1001,10 +1006,11 @@ class DoliDBMysql
|
||||
}
|
||||
|
||||
/**
|
||||
* Drop a field in table
|
||||
* @param table Nom de la table
|
||||
* @param field_name Nom du champ a inserer
|
||||
* @return int <0 si KO, >0 si OK
|
||||
* Drop a field from table
|
||||
*
|
||||
* @param string $table Name of table
|
||||
* @param string $field_name Name of field to drop
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function DDLDropField($table,$field_name)
|
||||
{
|
||||
@ -1020,12 +1026,13 @@ class DoliDBMysql
|
||||
|
||||
|
||||
/**
|
||||
* \brief Create a user and privileges to connect to database (even if database does not exists yet)
|
||||
* \param dolibarr_main_db_host Ip server
|
||||
* \param dolibarr_main_db_user Username to create
|
||||
* \param dolibarr_main_db_pass Password
|
||||
* \param dolibarr_main_db_name Database name where user must be granted
|
||||
* \return int <0 if KO, >=0 if OK
|
||||
* Create a user and privileges to connect to database (even if database does not exists yet)
|
||||
*
|
||||
* @param string $dolibarr_main_db_host Ip serveur
|
||||
* @param string $dolibarr_main_db_user Nom user a creer
|
||||
* @param string $dolibarr_main_db_pass Mot de passe user a creer
|
||||
* @param string $dolibarr_main_db_name Database name where user must be granted
|
||||
* @return int <0 if KO, >=0 if OK
|
||||
*/
|
||||
function DDLCreateUser($dolibarr_main_db_host,$dolibarr_main_db_user,$dolibarr_main_db_pass,$dolibarr_main_db_name)
|
||||
{
|
||||
@ -1069,8 +1076,9 @@ class DoliDBMysql
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Return charset used to store data in database
|
||||
* \return string Charset
|
||||
* Return charset used to store data in database
|
||||
*
|
||||
* @return string Charset
|
||||
*/
|
||||
function getDefaultCharacterSetDatabase()
|
||||
{
|
||||
@ -1085,8 +1093,9 @@ class DoliDBMysql
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Return list of available charset that can be used to store data in database
|
||||
* \return array List of Charset
|
||||
* Return list of available charset that can be used to store data in database
|
||||
*
|
||||
* @return array List of Charset
|
||||
*/
|
||||
function getListOfCharacterSet()
|
||||
{
|
||||
@ -1110,8 +1119,9 @@ class DoliDBMysql
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Return collation used in database
|
||||
* \return string Collation value
|
||||
* Return collation used in database
|
||||
*
|
||||
* @return string Collation value
|
||||
*/
|
||||
function getDefaultCollationDatabase()
|
||||
{
|
||||
@ -1126,8 +1136,9 @@ class DoliDBMysql
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Return list of available collation that can be used for database
|
||||
* \return array Liste of Collation
|
||||
* Return list of available collation that can be used for database
|
||||
*
|
||||
* @return array Liste of Collation
|
||||
*/
|
||||
function getListOfCollation()
|
||||
{
|
||||
@ -1151,6 +1162,7 @@ class DoliDBMysql
|
||||
|
||||
/**
|
||||
* Return full path of dump program
|
||||
*
|
||||
* @return string Full path of dump program
|
||||
*/
|
||||
function getPathOfDump()
|
||||
@ -1168,8 +1180,9 @@ class DoliDBMysql
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Return full path of restore program
|
||||
* \return string Full path of restore program
|
||||
* Return full path of restore program
|
||||
*
|
||||
* @return string Full path of restore program
|
||||
*/
|
||||
function getPathOfRestore()
|
||||
{
|
||||
@ -1186,9 +1199,10 @@ class DoliDBMysql
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Return value of server parameters
|
||||
* \param filter Filter list on a particular value
|
||||
* \return string Value for parameter
|
||||
* Return value of server parameters
|
||||
*
|
||||
* @param string $filter Filter list on a particular value
|
||||
* @return string Value for parameter
|
||||
*/
|
||||
function getServerParametersValues($filter='')
|
||||
{
|
||||
@ -1207,9 +1221,10 @@ class DoliDBMysql
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Return value of server status
|
||||
* \param filter Filter list on a particular value
|
||||
* \return string Value for parameter
|
||||
* Return value of server status
|
||||
*
|
||||
* @param string $filter Filter list on a particular value
|
||||
* @return string Value for parameter
|
||||
*/
|
||||
function getServerStatusValues($filter='')
|
||||
{
|
||||
|
||||
@ -813,10 +813,11 @@ class DoliDBMysqli
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief List tables into a database.
|
||||
* \param database Name of database
|
||||
* \param table Filter on some tables
|
||||
* \return array Array list of tables
|
||||
* List tables into a database
|
||||
*
|
||||
* @param string $database Name of database
|
||||
* @param string $table Nmae of table filter ('xxx%')
|
||||
* @return resource Resource
|
||||
*/
|
||||
function DDLListTables($database, $table='')
|
||||
{
|
||||
@ -835,9 +836,10 @@ class DoliDBMysqli
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Liste les informations des champs d'une table.
|
||||
* \param table Nom de la table
|
||||
* \return array Tableau des informations des champs de la table
|
||||
* List information of columns into a table.
|
||||
*
|
||||
* @param string $table Name of table
|
||||
* @return array Tableau des informations des champs de la table
|
||||
*/
|
||||
function DDLInfoTable($table)
|
||||
{
|
||||
@ -932,10 +934,11 @@ class DoliDBMysqli
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a pointer on fields describing table
|
||||
* @param table Nom de la table
|
||||
* @param field Optionnel : Nom du champ si l'on veut la desc d'un champ
|
||||
* @return resource
|
||||
* Return a pointer of line with description of a table or field
|
||||
*
|
||||
* @param string $table Name of table
|
||||
* @param string $field Optionnel : Name of field if we want description of field
|
||||
* @return resource Resource
|
||||
*/
|
||||
function DDLDescTable($table,$field="")
|
||||
{
|
||||
@ -947,12 +950,13 @@ class DoliDBMysqli
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert a new field in table
|
||||
* @param table Table name
|
||||
* @param field_name Name of field
|
||||
* @param field_desc Array with properties describing new field
|
||||
* @param field_position Optionnal ie.: "after fielddummy"
|
||||
* @return int <0 if KO, >0 if OK
|
||||
* Create a new field into table
|
||||
*
|
||||
* @param string $table Name of table
|
||||
* @param string $field_name Name of field to add
|
||||
* @param string $field_desc Tableau associatif de description du champ a inserer[nom du parametre][valeur du parametre]
|
||||
* @param string $field_position Optionnel ex.: "after champtruc"
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function DDLAddField($table,$field_name,$field_desc,$field_position="")
|
||||
{
|
||||
@ -992,11 +996,12 @@ class DoliDBMysqli
|
||||
}
|
||||
|
||||
/**
|
||||
* Update format of a field into a table
|
||||
* @param table Name of table
|
||||
* @param field_name Name of field to modify
|
||||
* @param field_desc Array with description of field format
|
||||
* @return int <0 if KO, >0 if OK
|
||||
* Update format of a field into a table
|
||||
*
|
||||
* @param string $table Name of table
|
||||
* @param string $field_name Name of field to modify
|
||||
* @param string $field_desc Array with description of field format
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function DDLUpdateField($table,$field_name,$field_desc)
|
||||
{
|
||||
@ -1012,10 +1017,11 @@ class DoliDBMysqli
|
||||
}
|
||||
|
||||
/**
|
||||
* Drop a field in table
|
||||
* @param table Nom de la table
|
||||
* @param field_name Nom du champ a inserer
|
||||
* @return int <0 si KO, >0 si OK
|
||||
* Drop a field from table
|
||||
*
|
||||
* @param string $table Name of table
|
||||
* @param string $field_name Name of field to drop
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function DDLDropField($table,$field_name)
|
||||
{
|
||||
@ -1031,12 +1037,13 @@ class DoliDBMysqli
|
||||
|
||||
|
||||
/**
|
||||
* \brief Create a user and privileges to connect to database (even if database does not exists yet)
|
||||
* \param dolibarr_main_db_host Ip server
|
||||
* \param dolibarr_main_db_user Username to create
|
||||
* \param dolibarr_main_db_pass Password
|
||||
* \param dolibarr_main_db_name Database name where user must be granted
|
||||
* \return int <0 if KO, >=0 if OK
|
||||
* Create a user and privileges to connect to database (even if database does not exists yet)
|
||||
*
|
||||
* @param string $dolibarr_main_db_host Ip serveur
|
||||
* @param string $dolibarr_main_db_user Nom user a creer
|
||||
* @param string $dolibarr_main_db_pass Mot de passe user a creer
|
||||
* @param string $dolibarr_main_db_name Database name where user must be granted
|
||||
* @return int <0 if KO, >=0 if OK
|
||||
*/
|
||||
function DDLCreateUser($dolibarr_main_db_host,$dolibarr_main_db_user,$dolibarr_main_db_pass,$dolibarr_main_db_name)
|
||||
{
|
||||
@ -1080,8 +1087,9 @@ class DoliDBMysqli
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Return charset used to store data in database
|
||||
* \return string Charset
|
||||
* Return charset used to store data in database
|
||||
*
|
||||
* @return string Charset
|
||||
*/
|
||||
function getDefaultCharacterSetDatabase()
|
||||
{
|
||||
@ -1096,8 +1104,9 @@ class DoliDBMysqli
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Return list of available charset that can be used to store data in database
|
||||
* \return array List of Charset
|
||||
* Return list of available charset that can be used to store data in database
|
||||
*
|
||||
* @return array List of Charset
|
||||
*/
|
||||
function getListOfCharacterSet()
|
||||
{
|
||||
@ -1121,8 +1130,9 @@ class DoliDBMysqli
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Return collation used in database
|
||||
* \return string Collation value
|
||||
* Return collation used in database
|
||||
*
|
||||
* @return string Collation value
|
||||
*/
|
||||
function getDefaultCollationDatabase()
|
||||
{
|
||||
@ -1137,8 +1147,9 @@ class DoliDBMysqli
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Return list of available collation that can be used for database
|
||||
* \return array Liste of Collation
|
||||
* Return list of available collation that can be used for database
|
||||
*
|
||||
* @return array Liste of Collation
|
||||
*/
|
||||
function getListOfCollation()
|
||||
{
|
||||
@ -1162,6 +1173,7 @@ class DoliDBMysqli
|
||||
|
||||
/**
|
||||
* Return full path of dump program
|
||||
*
|
||||
* @return string Full path of dump program
|
||||
*/
|
||||
function getPathOfDump()
|
||||
@ -1180,6 +1192,7 @@ class DoliDBMysqli
|
||||
|
||||
/**
|
||||
* Return full path of restore program
|
||||
*
|
||||
* @return string Full path of restore program
|
||||
*/
|
||||
function getPathOfRestore()
|
||||
@ -1197,9 +1210,10 @@ class DoliDBMysqli
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Return value of server parameters
|
||||
* \param filter Filter list on a particular value
|
||||
* \return string Value for parameter
|
||||
* Return value of server parameters
|
||||
*
|
||||
* @param string $filter Filter list on a particular value
|
||||
* @return string Value for parameter
|
||||
*/
|
||||
function getServerParametersValues($filter='')
|
||||
{
|
||||
@ -1218,9 +1232,10 @@ class DoliDBMysqli
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Return value of server status
|
||||
* \param filter Filter list on a particular value
|
||||
* \return string Value for parameter
|
||||
* Return value of server status
|
||||
*
|
||||
* @param string $filter Filter list on a particular value
|
||||
* @return string Value for parameter
|
||||
*/
|
||||
function getServerStatusValues($filter='')
|
||||
{
|
||||
|
||||
@ -342,52 +342,53 @@ class DoliDBPgsql
|
||||
/**
|
||||
* Connexion to server
|
||||
*
|
||||
* @param string $host database server host
|
||||
* @param string $login login
|
||||
* @param string $passwd password
|
||||
* @param string $name name of database (not used for mysql, used for pgsql)
|
||||
* @param string $port Port of database server
|
||||
* @return resource Database access handler
|
||||
* @param string $host Database server host
|
||||
* @param string $login Login
|
||||
* @param string $passwd Password
|
||||
* @param string $name Name of database (not used for mysql, used for pgsql)
|
||||
* @param string $port Port of database server
|
||||
* @return resource Database access handler
|
||||
* @see close
|
||||
*/
|
||||
function connect($host, $login, $passwd, $name, $port=0)
|
||||
{
|
||||
// use pg_connect() instead of pg_pconnect():
|
||||
// To us persistent connection because this one cost 1ms, non persistent cost 30ms
|
||||
|
||||
// use pg_pconnect() instead of pg_connect() if you want to use persistent connection costing 1ms, instead of 30ms for non persistent
|
||||
|
||||
$this->db = false;
|
||||
|
||||
|
||||
// connections parameters must be protected (only \ and ' according to pg_connect() manual)
|
||||
$host = str_replace(array("\\", "'"), array("\\\\", "\\'"), $host);
|
||||
$login = str_replace(array("\\", "'"), array("\\\\", "\\'"), $login);
|
||||
$passwd = str_replace(array("\\", "'"), array("\\\\", "\\'"), $passwd);
|
||||
$name = str_replace(array("\\", "'"), array("\\\\", "\\'"), $name);
|
||||
$port = str_replace(array("\\", "'"), array("\\\\", "\\'"), $port);
|
||||
|
||||
|
||||
//if (! $name) $name="postgres";
|
||||
|
||||
|
||||
// try first Unix domain socket (local)
|
||||
if (! $host || $host == "" || $host == "localhost")
|
||||
if (! $host || $host == "" || $host == "localhost" || $host == "127.0.0.1")
|
||||
{
|
||||
$con_string = "dbname='".$name."' user='".$login."' password='".$passwd."'";
|
||||
$this->db = pg_connect($con_string);
|
||||
}
|
||||
|
||||
|
||||
// if local connection failed or not requested, use TCP/IP
|
||||
if (! $this->db)
|
||||
{
|
||||
if (! $host) $host = "localhost";
|
||||
if (! $host) $host = "localhost";
|
||||
if (! $port) $port = 5432;
|
||||
|
||||
|
||||
$con_string = "host='".$host."' port='".$port."' dbname='".$name."' user='".$login."' password='".$passwd."'";
|
||||
$this->db = pg_connect($con_string);
|
||||
}
|
||||
else
|
||||
|
||||
// now we test if at least one connect method was a success
|
||||
if ($this->db)
|
||||
{
|
||||
$this->database_name = $name;
|
||||
pg_set_error_verbosity($this->db, PGSQL_ERRORS_VERBOSE); // Set verbosity to max
|
||||
}
|
||||
|
||||
|
||||
return $this->db;
|
||||
}
|
||||
|
||||
@ -629,9 +630,9 @@ class DoliDBPgsql
|
||||
/**
|
||||
* Renvoie le nombre de lignes dans le resultat d'une requete INSERT, DELETE ou UPDATE
|
||||
*
|
||||
* @see num_rows
|
||||
* @param Resultset $resultset Curseur de la requete voulue
|
||||
* @return int Nombre de lignes
|
||||
* @param Resultset $resultset Result set of request
|
||||
* @return int Nb of lines
|
||||
* @see num_rows
|
||||
*/
|
||||
function affected_rows($resultset)
|
||||
{
|
||||
@ -646,7 +647,7 @@ class DoliDBPgsql
|
||||
/**
|
||||
* Libere le dernier resultset utilise sur cette connexion
|
||||
*
|
||||
* @param Resultset $resultset Curseur de la requete voulue
|
||||
* @param Resultset $resultset Result set of request
|
||||
* @return void
|
||||
*/
|
||||
function free($resultset=0)
|
||||
@ -898,9 +899,9 @@ class DoliDBPgsql
|
||||
* Encrypt sensitive data in database
|
||||
* Warning: This function includes the escape, so it must use direct value
|
||||
*
|
||||
* @param fieldorvalue Field name or value to encrypt
|
||||
* @param withQuotes Return string with quotes
|
||||
* @return return XXX(field) or XXX('value') or field or 'value'
|
||||
* @param string $fieldorvalue Field name or value to encrypt
|
||||
* @param int $withQuotes Return string with quotes
|
||||
* @return return XXX(field) or XXX('value') or field or 'value'
|
||||
*/
|
||||
function encrypt($fieldorvalue, $withQuotes=0)
|
||||
{
|
||||
@ -920,8 +921,8 @@ class DoliDBPgsql
|
||||
/**
|
||||
* Decrypt sensitive data in database
|
||||
*
|
||||
* @param value Value to decrypt
|
||||
* @return return Decrypted value if used
|
||||
* @param int $value Value to decrypt
|
||||
* @return string Decrypted value if used
|
||||
*/
|
||||
function decrypt($value)
|
||||
{
|
||||
@ -958,11 +959,11 @@ class DoliDBPgsql
|
||||
* Create a new database
|
||||
* Ne pas utiliser les fonctions xxx_create_db (xxx=mysql, ...) car elles sont deprecated
|
||||
*
|
||||
* @param database Database name to create
|
||||
* @param charset Charset used to store data
|
||||
* @param collation Charset used to sort data
|
||||
* @param owner Username of database owner
|
||||
* @return resource resource defined if OK, null if KO
|
||||
* @param string $database Database name to create
|
||||
* @param string $charset Charset used to store data
|
||||
* @param string $collation Charset used to sort data
|
||||
* @param string $owner Username of database owner
|
||||
* @return resource Resource defined if OK, null if KO
|
||||
*/
|
||||
function DDLCreateDb($database,$charset='',$collation='',$owner='')
|
||||
{
|
||||
@ -974,9 +975,11 @@ class DoliDBPgsql
|
||||
}
|
||||
|
||||
/**
|
||||
* Liste des tables dans une database.
|
||||
* @param database Nom de la database
|
||||
* @return resource
|
||||
* List tables into a database
|
||||
*
|
||||
* @param string $database Name of database
|
||||
* @param string $table Nmae of table filter ('xxx%')
|
||||
* @return resource Resource
|
||||
*/
|
||||
function DDLListTables($database, $table='')
|
||||
{
|
||||
@ -993,10 +996,11 @@ class DoliDBPgsql
|
||||
}
|
||||
|
||||
/**
|
||||
* Liste les informations des champs d'une table.
|
||||
* @param table Nom de la table
|
||||
* @return array Tableau des informations des champs de la table
|
||||
* TODO modifier pour postgresql
|
||||
* List information of columns into a table.
|
||||
*
|
||||
* @param string $table Name of table
|
||||
* @return array Tableau des informations des champs de la table
|
||||
* TODO modify for postgresql
|
||||
*/
|
||||
function DDLInfoTable($table)
|
||||
{
|
||||
@ -1094,13 +1098,13 @@ class DoliDBPgsql
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a user
|
||||
* Create a user to connect to database
|
||||
*
|
||||
* @param dolibarr_main_db_host Ip serveur
|
||||
* @param dolibarr_main_db_user Nom user a creer
|
||||
* @param dolibarr_main_db_pass Mot de passe user a creer
|
||||
* @param dolibarr_main_db_name Database name where user must be granted
|
||||
* @return int <0 si KO, >=0 si OK
|
||||
* @param string $dolibarr_main_db_host Ip serveur
|
||||
* @param string $dolibarr_main_db_user Nom user a creer
|
||||
* @param string $dolibarr_main_db_pass Mot de passe user a creer
|
||||
* @param string $dolibarr_main_db_name Database name where user must be granted
|
||||
* @return int <0 if KO, >=0 if OK
|
||||
*/
|
||||
function DDLCreateUser($dolibarr_main_db_host,$dolibarr_main_db_user,$dolibarr_main_db_pass,$dolibarr_main_db_name)
|
||||
{
|
||||
@ -1117,11 +1121,11 @@ class DoliDBPgsql
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrit une table dans une database
|
||||
* Return a pointer of line with description of a table or field
|
||||
*
|
||||
* @param table Nom de la table
|
||||
* @param field Optionnel : Nom du champ si l'on veut la desc d'un champ
|
||||
* @return resource
|
||||
* @param string $table Name of table
|
||||
* @param string $field Optionnel : Name of field if we want description of field
|
||||
* @return resource Resource
|
||||
*/
|
||||
function DDLDescTable($table,$field="")
|
||||
{
|
||||
@ -1135,13 +1139,13 @@ class DoliDBPgsql
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert a new field in table
|
||||
* Create a new field into table
|
||||
*
|
||||
* @param table Nom de la table
|
||||
* @param field_name Nom du champ a inserer
|
||||
* @param field_desc Tableau associatif de description du champ a inserer[nom du parametre][valeur du parametre]
|
||||
* @param field_position Optionnel ex.: "after champtruc"
|
||||
* @return int <0 si KO, >0 si OK
|
||||
* @param string $table Name of table
|
||||
* @param string $field_name Name of field to add
|
||||
* @param string $field_desc Tableau associatif de description du champ a inserer[nom du parametre][valeur du parametre]
|
||||
* @param string $field_position Optionnel ex.: "after champtruc"
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function DDLAddField($table,$field_name,$field_desc,$field_position="")
|
||||
{
|
||||
@ -1174,10 +1178,10 @@ class DoliDBPgsql
|
||||
/**
|
||||
* Update format of a field into a table
|
||||
*
|
||||
* @param table Name of table
|
||||
* @param field_name Name of field to modify
|
||||
* @param field_desc Array with description of field format
|
||||
* @return int <0 if KO, >0 if OK
|
||||
* @param string $table Name of table
|
||||
* @param string $field_name Name of field to modify
|
||||
* @param string $field_desc Array with description of field format
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function DDLUpdateField($table,$field_name,$field_desc)
|
||||
{
|
||||
@ -1193,11 +1197,11 @@ class DoliDBPgsql
|
||||
}
|
||||
|
||||
/**
|
||||
* Drop a field in table
|
||||
* Drop a field from table
|
||||
*
|
||||
* @param table Nom de la table
|
||||
* @param field_name Nom du champ a inserer
|
||||
* @return int <0 si KO, >0 si OK
|
||||
* @param string $table Name of table
|
||||
* @param string $field_name Name of field to drop
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function DDLDropField($table,$field_name)
|
||||
{
|
||||
|
||||
@ -960,10 +960,11 @@ class DoliDBSqlite
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief List tables into a database.
|
||||
* \param database Name of database
|
||||
* \param table Filter on some tables
|
||||
* \return array Array list of tables
|
||||
* List tables into a database
|
||||
*
|
||||
* @param string $database Name of database
|
||||
* @param string $table Nmae of table filter ('xxx%')
|
||||
* @return resource Resource
|
||||
*/
|
||||
function DDLListTables($database, $table='')
|
||||
{
|
||||
@ -982,9 +983,11 @@ class DoliDBSqlite
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Liste les informations des champs d'une table.
|
||||
* \param table Nom de la table
|
||||
* \return array Tableau des informations des champs de la table
|
||||
* List information of columns into a table.
|
||||
*
|
||||
* @param string $table Name of table
|
||||
* @return array Tableau des informations des champs de la table
|
||||
* TODO modify for sqlite
|
||||
*/
|
||||
function DDLInfoTable($table)
|
||||
{
|
||||
@ -1079,10 +1082,11 @@ class DoliDBSqlite
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a pointer on fields describing table
|
||||
* @param table Nom de la table
|
||||
* @param field Optionnel : Nom du champ si l'on veut la desc d'un champ
|
||||
* @return resource
|
||||
* Return a pointer of line with description of a table or field
|
||||
*
|
||||
* @param string $table Name of table
|
||||
* @param string $field Optionnel : Name of field if we want description of field
|
||||
* @return resource Resource
|
||||
*/
|
||||
function DDLDescTable($table,$field="")
|
||||
{
|
||||
@ -1094,12 +1098,13 @@ class DoliDBSqlite
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert a new field in table
|
||||
* @param table Table name
|
||||
* @param field_name Name of field
|
||||
* @param field_desc Array with properties describing new field
|
||||
* @param field_position Optionnal ie.: "after fielddummy"
|
||||
* @return int <0 if KO, >0 if OK
|
||||
* Create a new field into table
|
||||
*
|
||||
* @param string $table Name of table
|
||||
* @param string $field_name Name of field to add
|
||||
* @param string $field_desc Tableau associatif de description du champ a inserer[nom du parametre][valeur du parametre]
|
||||
* @param string $field_position Optionnel ex.: "after champtruc"
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function DDLAddField($table,$field_name,$field_desc,$field_position="")
|
||||
{
|
||||
@ -1139,11 +1144,12 @@ class DoliDBSqlite
|
||||
}
|
||||
|
||||
/**
|
||||
* Update format of a field into a table
|
||||
* @param table Name of table
|
||||
* @param field_name Name of field to modify
|
||||
* @param field_desc Array with description of field format
|
||||
* @return int <0 if KO, >0 if OK
|
||||
* Update format of a field into a table
|
||||
*
|
||||
* @param string $table Name of table
|
||||
* @param string $field_name Name of field to modify
|
||||
* @param string $field_desc Array with description of field format
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function DDLUpdateField($table,$field_name,$field_desc)
|
||||
{
|
||||
@ -1159,10 +1165,11 @@ class DoliDBSqlite
|
||||
}
|
||||
|
||||
/**
|
||||
* Drop a field in table
|
||||
* @param table Nom de la table
|
||||
* @param field_name Nom du champ a inserer
|
||||
* @return int <0 si KO, >0 si OK
|
||||
* Drop a field from table
|
||||
*
|
||||
* @param string $table Name of table
|
||||
* @param string $field_name Name of field to drop
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function DDLDropField($table,$field_name)
|
||||
{
|
||||
@ -1178,12 +1185,13 @@ class DoliDBSqlite
|
||||
|
||||
|
||||
/**
|
||||
* \brief Create a user and privileges to connect to database (even if database does not exists yet)
|
||||
* \param dolibarr_main_db_host Ip server
|
||||
* \param dolibarr_main_db_user Username to create
|
||||
* \param dolibarr_main_db_pass Password
|
||||
* \param dolibarr_main_db_name Database name where user must be granted
|
||||
* \return int <0 if KO, >=0 if OK
|
||||
* Create a user and privileges to connect to database (even if database does not exists yet)
|
||||
*
|
||||
* @param string $dolibarr_main_db_host Ip serveur
|
||||
* @param string $dolibarr_main_db_user Nom user a creer
|
||||
* @param string $dolibarr_main_db_pass Mot de passe user a creer
|
||||
* @param string $dolibarr_main_db_name Database name where user must be granted
|
||||
* @return int <0 if KO, >=0 if OK
|
||||
*/
|
||||
function DDLCreateUser($dolibarr_main_db_host,$dolibarr_main_db_user,$dolibarr_main_db_pass,$dolibarr_main_db_name)
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user