Fix: error management of pgconnect

Doxygen
This commit is contained in:
Laurent Destailleur 2012-01-06 14:51:09 +01:00
parent f8fbc192d7
commit 427d099e87
5 changed files with 290 additions and 219 deletions

View File

@ -795,10 +795,11 @@ class DoliDBMssql
} }
/** /**
* \brief List tables into a database. * List tables into a database
* \param database Name of database *
* \param table Filter on some tables * @param string $database Name of database
* \return array Array list of tables * @param string $table Nmae of table filter ('xxx%')
* @return resource Resource
*/ */
function DDLListTables($database,$table='') function DDLListTables($database,$table='')
{ {
@ -884,10 +885,11 @@ class DoliDBMssql
} }
/** /**
\brief 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 * @param string $table Name of table
\return resource * @param string $field Optionnel : Name of field if we want description of field
* @return resource Resource
*/ */
function DDLDescTable($table,$field="") function DDLDescTable($table,$field="")
{ {
@ -899,12 +901,13 @@ class DoliDBMssql
} }
/** /**
* \brief 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 string $table Name of table
* \param field_desc Tableau associatif de description du champ a inserer[nom du parametre][valeur du parametre] * @param string $field_name Name of field to add
* \param field_position Optionnel ex.: "after champtruc" * @param string $field_desc Tableau associatif de description du champ a inserer[nom du parametre][valeur du parametre]
* \return int <0 si KO, >0 si OK * @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="") function DDLAddField($table,$field_name,$field_desc,$field_position="")
{ {
@ -935,9 +938,10 @@ class DoliDBMssql
/** /**
* Update format of a field into a table * Update format of a field into a table
* @param table Name of table *
* @param field_name Name of field to modify * @param string $table Name of table
* @param field_desc Array with description of field format * @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 * @return int <0 if KO, >0 if OK
*/ */
function DDLUpdateField($table,$field_name,$field_desc) function DDLUpdateField($table,$field_name,$field_desc)
@ -954,10 +958,11 @@ class DoliDBMssql
} }
/** /**
* \brief Drop a field in table * Drop a field from table
* \param table Nom de la table *
* \param field_name Nom du champ a inserer * @param string $table Name of table
* \return int <0 si KO, >0 si OK * @param string $field_name Name of field to drop
* @return int <0 if KO, >0 if OK
*/ */
function DDLDropField($table,$field_name) 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\''); $resql=$this->query('SHOW VARIABLES LIKE \'character_set_database\'');
if (!$resql) if (!$resql)
@ -985,7 +996,13 @@ class DoliDBMssql
return ''; 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'); $resql=$this->query('SHOW CHARSET');
$liste = array(); $liste = array();
@ -1007,6 +1024,11 @@ class DoliDBMssql
return ''; // attente debuggage return ''; // attente debuggage
} }
/**
* Return collation used in database
*
* @return string Collation value
*/
function getDefaultCollationDatabase() function getDefaultCollationDatabase()
{ {
$resql=$this->query("SELECT SERVERPROPERTY('collation')"); $resql=$this->query("SELECT SERVERPROPERTY('collation')");
@ -1018,6 +1040,11 @@ class DoliDBMssql
return $liste['computed']; return $liste['computed'];
} }
/**
* Return list of available collation that can be used for database
*
* @return array Liste of Collation
*/
function getListOfCollation() function getListOfCollation()
{ {
/* /*
@ -1040,8 +1067,9 @@ class DoliDBMssql
return ''; // attente debugage return ''; // attente debugage
} }
/* /**
* Return full path of dump program * Return full path of dump program
*
* @return string Full path of dump program * @return string Full path of dump program
*/ */
function getPathOfDump() function getPathOfDump()
@ -1052,6 +1080,7 @@ class DoliDBMssql
/** /**
* Return full path of restore program * Return full path of restore program
*
* @return string Full path of restore program * @return string Full path of restore program
*/ */
function getPathOfRestore() function getPathOfRestore()

View File

@ -802,10 +802,11 @@ class DoliDBMysql
} }
/** /**
* \brief List tables into a database. * List tables into a database
* \param database Name of database *
* \param table Filter on some tables * @param string $database Name of database
* \return array Array list of tables * @param string $table Nmae of table filter ('xxx%')
* @return resource Resource
*/ */
function DDLListTables($database, $table='') function DDLListTables($database, $table='')
{ {
@ -824,9 +825,10 @@ class DoliDBMysql
} }
/** /**
* \brief Liste les informations des champs d'une table. * List information of columns into a table.
* \param table Nom de la table *
* \return array Tableau des informations des champs de la table * @param string $table Name of table
* @return array Tableau des informations des champs de la table
*/ */
function DDLInfoTable($table) function DDLInfoTable($table)
{ {
@ -921,10 +923,11 @@ class DoliDBMysql
} }
/** /**
* Return a pointer on fields describing table * 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 * @param string $table Name of table
* @return resource * @param string $field Optionnel : Name of field if we want description of field
* @return resource Resource
*/ */
function DDLDescTable($table,$field="") function DDLDescTable($table,$field="")
{ {
@ -936,11 +939,12 @@ class DoliDBMysql
} }
/** /**
* Insert a new field in table * Create a new field into table
* @param table Table name *
* @param field_name Name of field * @param string $table Name of table
* @param field_desc Array with properties describing new field * @param string $field_name Name of field to add
* @param field_position Optionnal ie.: "after fielddummy" * @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 * @return int <0 if KO, >0 if OK
*/ */
function DDLAddField($table,$field_name,$field_desc,$field_position="") function DDLAddField($table,$field_name,$field_desc,$field_position="")
@ -982,9 +986,10 @@ class DoliDBMysql
/** /**
* Update format of a field into a table * Update format of a field into a table
* @param table Name of table *
* @param field_name Name of field to modify * @param string $table Name of table
* @param field_desc Array with description of field format * @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 * @return int <0 if KO, >0 if OK
*/ */
function DDLUpdateField($table,$field_name,$field_desc) function DDLUpdateField($table,$field_name,$field_desc)
@ -1001,10 +1006,11 @@ class DoliDBMysql
} }
/** /**
* Drop a field in table * Drop a field from table
* @param table Nom de la table *
* @param field_name Nom du champ a inserer * @param string $table Name of table
* @return int <0 si KO, >0 si OK * @param string $field_name Name of field to drop
* @return int <0 if KO, >0 if OK
*/ */
function DDLDropField($table,$field_name) 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) * 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 string $dolibarr_main_db_host Ip serveur
* \param dolibarr_main_db_pass Password * @param string $dolibarr_main_db_user Nom user a creer
* \param dolibarr_main_db_name Database name where user must be granted * @param string $dolibarr_main_db_pass Mot de passe user a creer
* \return int <0 if KO, >=0 if OK * @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) 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 charset used to store data in database
* \return string Charset *
* @return string Charset
*/ */
function getDefaultCharacterSetDatabase() function getDefaultCharacterSetDatabase()
{ {
@ -1085,8 +1093,9 @@ class DoliDBMysql
} }
/** /**
* \brief Return list of available charset that can be used to store data in database * Return list of available charset that can be used to store data in database
* \return array List of Charset *
* @return array List of Charset
*/ */
function getListOfCharacterSet() function getListOfCharacterSet()
{ {
@ -1110,8 +1119,9 @@ class DoliDBMysql
} }
/** /**
* \brief Return collation used in database * Return collation used in database
* \return string Collation value *
* @return string Collation value
*/ */
function getDefaultCollationDatabase() function getDefaultCollationDatabase()
{ {
@ -1126,8 +1136,9 @@ class DoliDBMysql
} }
/** /**
* \brief Return list of available collation that can be used for database * Return list of available collation that can be used for database
* \return array Liste of Collation *
* @return array Liste of Collation
*/ */
function getListOfCollation() function getListOfCollation()
{ {
@ -1151,6 +1162,7 @@ class DoliDBMysql
/** /**
* Return full path of dump program * Return full path of dump program
*
* @return string Full path of dump program * @return string Full path of dump program
*/ */
function getPathOfDump() function getPathOfDump()
@ -1168,8 +1180,9 @@ class DoliDBMysql
} }
/** /**
* \brief Return full path of restore program * Return full path of restore program
* \return string Full path of restore program *
* @return string Full path of restore program
*/ */
function getPathOfRestore() function getPathOfRestore()
{ {
@ -1186,9 +1199,10 @@ class DoliDBMysql
} }
/** /**
* \brief Return value of server parameters * Return value of server parameters
* \param filter Filter list on a particular value *
* \return string Value for parameter * @param string $filter Filter list on a particular value
* @return string Value for parameter
*/ */
function getServerParametersValues($filter='') function getServerParametersValues($filter='')
{ {
@ -1207,9 +1221,10 @@ class DoliDBMysql
} }
/** /**
* \brief Return value of server status * Return value of server status
* \param filter Filter list on a particular value *
* \return string Value for parameter * @param string $filter Filter list on a particular value
* @return string Value for parameter
*/ */
function getServerStatusValues($filter='') function getServerStatusValues($filter='')
{ {

View File

@ -813,10 +813,11 @@ class DoliDBMysqli
} }
/** /**
* \brief List tables into a database. * List tables into a database
* \param database Name of database *
* \param table Filter on some tables * @param string $database Name of database
* \return array Array list of tables * @param string $table Nmae of table filter ('xxx%')
* @return resource Resource
*/ */
function DDLListTables($database, $table='') function DDLListTables($database, $table='')
{ {
@ -835,9 +836,10 @@ class DoliDBMysqli
} }
/** /**
* \brief Liste les informations des champs d'une table. * List information of columns into a table.
* \param table Nom de la table *
* \return array Tableau des informations des champs de la table * @param string $table Name of table
* @return array Tableau des informations des champs de la table
*/ */
function DDLInfoTable($table) function DDLInfoTable($table)
{ {
@ -932,10 +934,11 @@ class DoliDBMysqli
} }
/** /**
* Return a pointer on fields describing table * 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 * @param string $table Name of table
* @return resource * @param string $field Optionnel : Name of field if we want description of field
* @return resource Resource
*/ */
function DDLDescTable($table,$field="") function DDLDescTable($table,$field="")
{ {
@ -947,11 +950,12 @@ class DoliDBMysqli
} }
/** /**
* Insert a new field in table * Create a new field into table
* @param table Table name *
* @param field_name Name of field * @param string $table Name of table
* @param field_desc Array with properties describing new field * @param string $field_name Name of field to add
* @param field_position Optionnal ie.: "after fielddummy" * @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 * @return int <0 if KO, >0 if OK
*/ */
function DDLAddField($table,$field_name,$field_desc,$field_position="") function DDLAddField($table,$field_name,$field_desc,$field_position="")
@ -993,9 +997,10 @@ class DoliDBMysqli
/** /**
* Update format of a field into a table * Update format of a field into a table
* @param table Name of table *
* @param field_name Name of field to modify * @param string $table Name of table
* @param field_desc Array with description of field format * @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 * @return int <0 if KO, >0 if OK
*/ */
function DDLUpdateField($table,$field_name,$field_desc) function DDLUpdateField($table,$field_name,$field_desc)
@ -1012,10 +1017,11 @@ class DoliDBMysqli
} }
/** /**
* Drop a field in table * Drop a field from table
* @param table Nom de la table *
* @param field_name Nom du champ a inserer * @param string $table Name of table
* @return int <0 si KO, >0 si OK * @param string $field_name Name of field to drop
* @return int <0 if KO, >0 if OK
*/ */
function DDLDropField($table,$field_name) 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) * 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 string $dolibarr_main_db_host Ip serveur
* \param dolibarr_main_db_pass Password * @param string $dolibarr_main_db_user Nom user a creer
* \param dolibarr_main_db_name Database name where user must be granted * @param string $dolibarr_main_db_pass Mot de passe user a creer
* \return int <0 if KO, >=0 if OK * @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) 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 charset used to store data in database
* \return string Charset *
* @return string Charset
*/ */
function getDefaultCharacterSetDatabase() function getDefaultCharacterSetDatabase()
{ {
@ -1096,8 +1104,9 @@ class DoliDBMysqli
} }
/** /**
* \brief Return list of available charset that can be used to store data in database * Return list of available charset that can be used to store data in database
* \return array List of Charset *
* @return array List of Charset
*/ */
function getListOfCharacterSet() function getListOfCharacterSet()
{ {
@ -1121,8 +1130,9 @@ class DoliDBMysqli
} }
/** /**
* \brief Return collation used in database * Return collation used in database
* \return string Collation value *
* @return string Collation value
*/ */
function getDefaultCollationDatabase() function getDefaultCollationDatabase()
{ {
@ -1137,8 +1147,9 @@ class DoliDBMysqli
} }
/** /**
* \brief Return list of available collation that can be used for database * Return list of available collation that can be used for database
* \return array Liste of Collation *
* @return array Liste of Collation
*/ */
function getListOfCollation() function getListOfCollation()
{ {
@ -1162,6 +1173,7 @@ class DoliDBMysqli
/** /**
* Return full path of dump program * Return full path of dump program
*
* @return string Full path of dump program * @return string Full path of dump program
*/ */
function getPathOfDump() function getPathOfDump()
@ -1180,6 +1192,7 @@ class DoliDBMysqli
/** /**
* Return full path of restore program * Return full path of restore program
*
* @return string Full path of restore program * @return string Full path of restore program
*/ */
function getPathOfRestore() function getPathOfRestore()
@ -1197,9 +1210,10 @@ class DoliDBMysqli
} }
/** /**
* \brief Return value of server parameters * Return value of server parameters
* \param filter Filter list on a particular value *
* \return string Value for parameter * @param string $filter Filter list on a particular value
* @return string Value for parameter
*/ */
function getServerParametersValues($filter='') function getServerParametersValues($filter='')
{ {
@ -1218,9 +1232,10 @@ class DoliDBMysqli
} }
/** /**
* \brief Return value of server status * Return value of server status
* \param filter Filter list on a particular value *
* \return string Value for parameter * @param string $filter Filter list on a particular value
* @return string Value for parameter
*/ */
function getServerStatusValues($filter='') function getServerStatusValues($filter='')
{ {

View File

@ -342,18 +342,17 @@ class DoliDBPgsql
/** /**
* Connexion to server * Connexion to server
* *
* @param string $host database server host * @param string $host Database server host
* @param string $login login * @param string $login Login
* @param string $passwd password * @param string $passwd Password
* @param string $name name of database (not used for mysql, used for pgsql) * @param string $name Name of database (not used for mysql, used for pgsql)
* @param string $port Port of database server * @param string $port Port of database server
* @return resource Database access handler * @return resource Database access handler
* @see close * @see close
*/ */
function connect($host, $login, $passwd, $name, $port=0) function connect($host, $login, $passwd, $name, $port=0)
{ {
// use pg_connect() instead of pg_pconnect(): // use pg_pconnect() instead of pg_connect() if you want to use persistent connection costing 1ms, instead of 30ms for non persistent
// To us persistent connection because this one cost 1ms, non persistent cost 30ms
$this->db = false; $this->db = false;
@ -367,7 +366,7 @@ class DoliDBPgsql
//if (! $name) $name="postgres"; //if (! $name) $name="postgres";
// try first Unix domain socket (local) // 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."'"; $con_string = "dbname='".$name."' user='".$login."' password='".$passwd."'";
$this->db = pg_connect($con_string); $this->db = pg_connect($con_string);
@ -382,7 +381,9 @@ class DoliDBPgsql
$con_string = "host='".$host."' port='".$port."' dbname='".$name."' user='".$login."' password='".$passwd."'"; $con_string = "host='".$host."' port='".$port."' dbname='".$name."' user='".$login."' password='".$passwd."'";
$this->db = pg_connect($con_string); $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; $this->database_name = $name;
pg_set_error_verbosity($this->db, PGSQL_ERRORS_VERBOSE); // Set verbosity to max pg_set_error_verbosity($this->db, PGSQL_ERRORS_VERBOSE); // Set verbosity to max
@ -629,9 +630,9 @@ class DoliDBPgsql
/** /**
* Renvoie le nombre de lignes dans le resultat d'une requete INSERT, DELETE ou UPDATE * Renvoie le nombre de lignes dans le resultat d'une requete INSERT, DELETE ou UPDATE
* *
* @param Resultset $resultset Result set of request
* @return int Nb of lines
* @see num_rows * @see num_rows
* @param Resultset $resultset Curseur de la requete voulue
* @return int Nombre de lignes
*/ */
function affected_rows($resultset) function affected_rows($resultset)
{ {
@ -646,7 +647,7 @@ class DoliDBPgsql
/** /**
* Libere le dernier resultset utilise sur cette connexion * 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 * @return void
*/ */
function free($resultset=0) function free($resultset=0)
@ -898,8 +899,8 @@ class DoliDBPgsql
* Encrypt sensitive data in database * Encrypt sensitive data in database
* Warning: This function includes the escape, so it must use direct value * Warning: This function includes the escape, so it must use direct value
* *
* @param fieldorvalue Field name or value to encrypt * @param string $fieldorvalue Field name or value to encrypt
* @param withQuotes Return string with quotes * @param int $withQuotes Return string with quotes
* @return return XXX(field) or XXX('value') or field or 'value' * @return return XXX(field) or XXX('value') or field or 'value'
*/ */
function encrypt($fieldorvalue, $withQuotes=0) function encrypt($fieldorvalue, $withQuotes=0)
@ -920,8 +921,8 @@ class DoliDBPgsql
/** /**
* Decrypt sensitive data in database * Decrypt sensitive data in database
* *
* @param value Value to decrypt * @param int $value Value to decrypt
* @return return Decrypted value if used * @return string Decrypted value if used
*/ */
function decrypt($value) function decrypt($value)
{ {
@ -958,11 +959,11 @@ class DoliDBPgsql
* Create a new database * Create a new database
* Ne pas utiliser les fonctions xxx_create_db (xxx=mysql, ...) car elles sont deprecated * Ne pas utiliser les fonctions xxx_create_db (xxx=mysql, ...) car elles sont deprecated
* *
* @param database Database name to create * @param string $database Database name to create
* @param charset Charset used to store data * @param string $charset Charset used to store data
* @param collation Charset used to sort data * @param string $collation Charset used to sort data
* @param owner Username of database owner * @param string $owner Username of database owner
* @return resource resource defined if OK, null if KO * @return resource Resource defined if OK, null if KO
*/ */
function DDLCreateDb($database,$charset='',$collation='',$owner='') function DDLCreateDb($database,$charset='',$collation='',$owner='')
{ {
@ -974,9 +975,11 @@ class DoliDBPgsql
} }
/** /**
* Liste des tables dans une database. * List tables into a database
* @param database Nom de la database *
* @return resource * @param string $database Name of database
* @param string $table Nmae of table filter ('xxx%')
* @return resource Resource
*/ */
function DDLListTables($database, $table='') function DDLListTables($database, $table='')
{ {
@ -993,10 +996,11 @@ class DoliDBPgsql
} }
/** /**
* Liste les informations des champs d'une table. * List information of columns into a table.
* @param table Nom de la table *
* @param string $table Name of table
* @return array Tableau des informations des champs de la table * @return array Tableau des informations des champs de la table
* TODO modifier pour postgresql * TODO modify for postgresql
*/ */
function DDLInfoTable($table) 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 string $dolibarr_main_db_host Ip serveur
* @param dolibarr_main_db_user Nom user a creer * @param string $dolibarr_main_db_user Nom user a creer
* @param dolibarr_main_db_pass Mot de passe user a creer * @param string $dolibarr_main_db_pass Mot de passe user a creer
* @param dolibarr_main_db_name Database name where user must be granted * @param string $dolibarr_main_db_name Database name where user must be granted
* @return int <0 si KO, >=0 si OK * @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) 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 string $table Name of table
* @param field Optionnel : Nom du champ si l'on veut la desc d'un champ * @param string $field Optionnel : Name of field if we want description of field
* @return resource * @return resource Resource
*/ */
function DDLDescTable($table,$field="") 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 string $table Name of table
* @param field_name Nom du champ a inserer * @param string $field_name Name of field to add
* @param field_desc Tableau associatif de description du champ a inserer[nom du parametre][valeur du parametre] * @param string $field_desc Tableau associatif de description du champ a inserer[nom du parametre][valeur du parametre]
* @param field_position Optionnel ex.: "after champtruc" * @param string $field_position Optionnel ex.: "after champtruc"
* @return int <0 si KO, >0 si OK * @return int <0 if KO, >0 if OK
*/ */
function DDLAddField($table,$field_name,$field_desc,$field_position="") function DDLAddField($table,$field_name,$field_desc,$field_position="")
{ {
@ -1174,9 +1178,9 @@ class DoliDBPgsql
/** /**
* Update format of a field into a table * Update format of a field into a table
* *
* @param table Name of table * @param string $table Name of table
* @param field_name Name of field to modify * @param string $field_name Name of field to modify
* @param field_desc Array with description of field format * @param string $field_desc Array with description of field format
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function DDLUpdateField($table,$field_name,$field_desc) 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 string $table Name of table
* @param field_name Nom du champ a inserer * @param string $field_name Name of field to drop
* @return int <0 si KO, >0 si OK * @return int <0 if KO, >0 if OK
*/ */
function DDLDropField($table,$field_name) function DDLDropField($table,$field_name)
{ {

View File

@ -960,10 +960,11 @@ class DoliDBSqlite
} }
/** /**
* \brief List tables into a database. * List tables into a database
* \param database Name of database *
* \param table Filter on some tables * @param string $database Name of database
* \return array Array list of tables * @param string $table Nmae of table filter ('xxx%')
* @return resource Resource
*/ */
function DDLListTables($database, $table='') function DDLListTables($database, $table='')
{ {
@ -982,9 +983,11 @@ class DoliDBSqlite
} }
/** /**
* \brief Liste les informations des champs d'une table. * List information of columns into a table.
* \param table Nom de la table *
* \return array Tableau des informations des champs de la table * @param string $table Name of table
* @return array Tableau des informations des champs de la table
* TODO modify for sqlite
*/ */
function DDLInfoTable($table) function DDLInfoTable($table)
{ {
@ -1079,10 +1082,11 @@ class DoliDBSqlite
} }
/** /**
* Return a pointer on fields describing table * 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 * @param string $table Name of table
* @return resource * @param string $field Optionnel : Name of field if we want description of field
* @return resource Resource
*/ */
function DDLDescTable($table,$field="") function DDLDescTable($table,$field="")
{ {
@ -1094,11 +1098,12 @@ class DoliDBSqlite
} }
/** /**
* Insert a new field in table * Create a new field into table
* @param table Table name *
* @param field_name Name of field * @param string $table Name of table
* @param field_desc Array with properties describing new field * @param string $field_name Name of field to add
* @param field_position Optionnal ie.: "after fielddummy" * @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 * @return int <0 if KO, >0 if OK
*/ */
function DDLAddField($table,$field_name,$field_desc,$field_position="") function DDLAddField($table,$field_name,$field_desc,$field_position="")
@ -1140,9 +1145,10 @@ class DoliDBSqlite
/** /**
* Update format of a field into a table * Update format of a field into a table
* @param table Name of table *
* @param field_name Name of field to modify * @param string $table Name of table
* @param field_desc Array with description of field format * @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 * @return int <0 if KO, >0 if OK
*/ */
function DDLUpdateField($table,$field_name,$field_desc) function DDLUpdateField($table,$field_name,$field_desc)
@ -1159,10 +1165,11 @@ class DoliDBSqlite
} }
/** /**
* Drop a field in table * Drop a field from table
* @param table Nom de la table *
* @param field_name Nom du champ a inserer * @param string $table Name of table
* @return int <0 si KO, >0 si OK * @param string $field_name Name of field to drop
* @return int <0 if KO, >0 if OK
*/ */
function DDLDropField($table,$field_name) 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) * 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 string $dolibarr_main_db_host Ip serveur
* \param dolibarr_main_db_pass Password * @param string $dolibarr_main_db_user Nom user a creer
* \param dolibarr_main_db_name Database name where user must be granted * @param string $dolibarr_main_db_pass Mot de passe user a creer
* \return int <0 if KO, >=0 if OK * @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) function DDLCreateUser($dolibarr_main_db_host,$dolibarr_main_db_user,$dolibarr_main_db_pass,$dolibarr_main_db_name)
{ {