Fix phpcs

This commit is contained in:
Laurent Destailleur 2015-04-06 11:28:06 +02:00
parent f40bb3e6aa
commit 8fb14b122a
2 changed files with 155 additions and 155 deletions

View File

@ -26,95 +26,95 @@
interface Database interface Database
{ {
/** /**
* Format a SQL IF * Format a SQL IF
* *
* @param string $test Test string (example: 'cd.statut=0', 'field IS NULL') * @param string $test Test string (example: 'cd.statut=0', 'field IS NULL')
* @param string $resok resultat si test egal * @param string $resok resultat si test egal
* @param string $resko resultat si test non egal * @param string $resko resultat si test non egal
* @return string SQL string * @return string SQL string
*/ */
function ifsql($test, $resok, $resko); function ifsql($test, $resok, $resko);
/** /**
* Return datas as an array * Return datas as an array
* *
* @param resource $resultset Resultset of request * @param resource $resultset Resultset of request
* @return array Array * @return array Array
*/ */
function fetch_row($resultset); function fetch_row($resultset);
/** /**
* Convert (by PHP) a GM Timestamp date into a string date with PHP server TZ to insert into a date field. * Convert (by PHP) a GM Timestamp date into a string date with PHP server TZ to insert into a date field.
* Function to use to build INSERT, UPDATE or WHERE predica * Function to use to build INSERT, UPDATE or WHERE predica
* *
* @param string $param Date TMS to convert * @param int $param Date TMS to convert
* @return string Date in a string YYYYMMDDHHMMSS * @return string Date in a string YYYYMMDDHHMMSS
*/ */
function idate($param); function idate($param);
/** /**
* Return last error code * Return last error code
* *
* @return string lasterrno * @return string lasterrno
*/ */
function lasterrno(); function lasterrno();
/** /**
* Start transaction * Start transaction
* *
* @return int 1 if transaction successfuly opened or already opened, 0 if error * @return int 1 if transaction successfuly opened or already opened, 0 if error
*/ */
function begin(); function begin();
/** /**
* Create a new database * Create a new database
* Do not use function xxx_create_db (xxx=mysql, ...) as they are deprecated * Do not use function xxx_create_db (xxx=mysql, ...) as they are deprecated
* We force to create database with charset this->forcecharset and collate this->forcecollate * We force to create database with charset this->forcecharset and collate this->forcecollate
* *
* @param string $database Database name to create * @param string $database Database name to create
* @param string $charset Charset used to store data * @param string $charset Charset used to store data
* @param string $collation Charset used to sort data * @param string $collation Charset used to sort data
* @param string $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 = '');
/** /**
* Return version of database server into an array * Return version of database server into an array
* *
* @return array Version array * @return array Version array
*/ */
function getVersionArray(); function getVersionArray();
/** /**
* Convert a SQL request in Mysql syntax to native syntax * Convert a SQL request in Mysql syntax to native syntax
* *
* @param string $line SQL request line to convert * @param string $line SQL request line to convert
* @param string $type Type of SQL order ('ddl' for insert, update, select, delete or 'dml' for create, alter...) * @param string $type Type of SQL order ('ddl' for insert, update, select, delete or 'dml' for create, alter...)
* @return string SQL request line converted * @return string SQL request line converted
*/ */
static function convertSQLFromMysql($line, $type = 'ddl'); static function convertSQLFromMysql($line, $type = 'ddl');
/** /**
* 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 resource $resultset Curseur de la requete voulue * @param resource $resultset Curseur de la requete voulue
* @return int Nombre de lignes * @return int Nombre de lignes
* @see num_rows * @see num_rows
*/ */
function affected_rows($resultset); function affected_rows($resultset);
/** /**
* Return description of last error * Return description of last error
* *
* @return string Error text * @return string Error text
*/ */
function error(); function error();
/** /**
* Return label of manager * Return label of manager
* *
* @return string Label * @return string Label
*/ */
function getLabel(); function getLabel();
@ -128,58 +128,58 @@ interface Database
function DDLListTables($database, $table = ''); function DDLListTables($database, $table = '');
/** /**
* Return last request executed with query() * Return last request executed with query()
* *
* @return string Last query * @return string Last query
*/ */
function lastquery(); function lastquery();
/** /**
* Define sort criteria of request * Define sort criteria of request
* *
* @param string $sortfield List of sort fields * @param string $sortfield List of sort fields
* @param string $sortorder Sort order * @param string $sortorder Sort order
* @return string String to provide syntax of a sort sql string * @return string String to provide syntax of a sort sql string
*/ */
function order($sortfield = 0, $sortorder = 0); function order($sortfield = 0, $sortorder = 0);
/** /**
* Decrypt sensitive data in database * Decrypt sensitive data in database
* *
* @param string $value Value to decrypt * @param string $value Value to decrypt
* @return string Decrypted value if used * @return string Decrypted value if used
*/ */
function decrypt($value); function decrypt($value);
/** /**
* Return datas as an array * Return datas as an array
* *
* @param resource $resultset Resultset of request * @param resource $resultset Resultset of request
* @return array Array * @return array Array
*/ */
function fetch_array($resultset); function fetch_array($resultset);
/** /**
* Return last error label * Return last error label
* *
* @return string lasterror * @return string lasterror
*/ */
function lasterror(); function lasterror();
/** /**
* Escape a string to insert data * Escape a string to insert data
* *
* @param string $stringtoencode String to escape * @param string $stringtoencode String to escape
* @return string String escaped * @return string String escaped
*/ */
function escape($stringtoencode); function escape($stringtoencode);
/** /**
* Get last ID after an insert INSERT * Get last ID after an insert INSERT
* *
* @param string $tab Table name concerned by insert. Ne sert pas sous MySql mais requis pour compatibilite avec Postgresql * @param string $tab Table name concerned by insert. Ne sert pas sous MySql mais requis pour compatibilite avec Postgresql
* @param string $fieldid Field name * @param string $fieldid Field name
* @return int Id of row * @return int Id of row
*/ */
function last_insert_id($tab, $fieldid = 'rowid'); function last_insert_id($tab, $fieldid = 'rowid');
@ -193,186 +193,186 @@ interface Database
/** /**
* Annulation d'une transaction et retour aux anciennes valeurs * Annulation d'une transaction et retour aux anciennes valeurs
* *
* @param string $log Add more log to default log line * @param string $log Add more log to default log line
* @return int 1 si annulation ok ou transaction non ouverte, 0 en cas d'erreur * @return int 1 si annulation ok ou transaction non ouverte, 0 en cas d'erreur
*/ */
function rollback($log = ''); function rollback($log = '');
/** /**
* Execute a SQL request and return the resultset * Execute a SQL request and return the resultset
* *
* @param string $query SQL query string * @param string $query SQL query string
* @param int $usesavepoint 0=Default mode, 1=Run a savepoint before and a rollbock to savepoint if error (this allow to have some request with errors inside global transactions). * @param int $usesavepoint 0=Default mode, 1=Run a savepoint before and a rollbock to savepoint if error (this allow to have some request with errors inside global transactions).
* Note that with Mysql, this parameter is not used as Myssql can already commit a transaction even if one request is in error, without using savepoints. * Note that with Mysql, this parameter is not used as Myssql can already commit a transaction even if one request is in error, without using savepoints.
* @param string $type Type of SQL order ('ddl' for insert, update, select, delete or 'dml' for create, alter...) * @param string $type Type of SQL order ('ddl' for insert, update, select, delete or 'dml' for create, alter...)
* @return resource Resultset of answer * @return resource Resultset of answer
*/ */
function query($query, $usesavepoint = 0, $type = 'auto'); function query($query, $usesavepoint = 0, $type = 'auto');
/** /**
* 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);
/** /**
* Define limits and offset of request * Define limits and offset of request
* *
* @param int $limit Maximum number of lines returned (-1=conf->liste_limit, 0=no limit) * @param int $limit Maximum number of lines returned (-1=conf->liste_limit, 0=no limit)
* @param int $offset Numero of line from where starting fetch * @param int $offset Numero of line from where starting fetch
* @return string String with SQL syntax to add a limit and offset * @return string String with SQL syntax to add a limit and offset
*/ */
function plimit($limit = 0, $offset = 0); function plimit($limit = 0, $offset = 0);
/** /**
* Return value of server parameters * Return value of server parameters
* *
* @param string $filter Filter list on a particular value * @param string $filter Filter list on a particular value
* @return array Array of key-values (key=>value) * @return array Array of key-values (key=>value)
*/ */
function getServerParametersValues($filter = ''); function getServerParametersValues($filter = '');
/** /**
* Return value of server status * Return value of server status
* *
* @param string $filter Filter list on a particular value * @param string $filter Filter list on a particular value
* @return array Array of key-values (key=>value) * @return array Array of key-values (key=>value)
*/ */
function getServerStatusValues($filter = ''); function getServerStatusValues($filter = '');
/** /**
* Return collation used in database * Return collation used in database
* *
* @return string Collation value * @return string Collation value
*/ */
function getDefaultCollationDatabase(); function getDefaultCollationDatabase();
/** /**
* Return number of lines for result of a SELECT * Return number of lines for result of a SELECT
* *
* @param resource $resultset Resulset of requests * @param resource $resultset Resulset of requests
* @return int Nb of lines * @return int Nb of lines
* @see affected_rows * @see affected_rows
*/ */
function num_rows($resultset); function num_rows($resultset);
/** /**
* 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();
/** /**
* Return version of database client driver * Return version of database client driver
* *
* @return string Version string * @return string Version string
*/ */
function getDriverInfo(); function getDriverInfo();
/** /**
* Return generic error code of last operation. * Return generic error code of last operation.
* *
* @return string Error code (Exemples: DB_ERROR_TABLE_ALREADY_EXISTS, DB_ERROR_RECORD_ALREADY_EXISTS...) * @return string Error code (Exemples: DB_ERROR_TABLE_ALREADY_EXISTS, DB_ERROR_RECORD_ALREADY_EXISTS...)
*/ */
function errno(); function errno();
/** /**
* Create a table into database * Create a table into database
* *
* @param string $table Nom de la table * @param string $table Nom de la table
* @param array $fields Tableau associatif [nom champ][tableau des descriptions] * @param array $fields Tableau associatif [nom champ][tableau des descriptions]
* @param string $primary_key Nom du champ qui sera la clef primaire * @param string $primary_key Nom du champ qui sera la clef primaire
* @param string $type Type de la table * @param string $type Type de la table
* @param array $unique_keys Tableau associatifs Nom de champs qui seront clef unique => valeur * @param array $unique_keys Tableau associatifs Nom de champs qui seront clef unique => valeur
* @param array $fulltext_keys Tableau des Nom de champs qui seront indexes en fulltext * @param array $fulltext_keys Tableau des Nom de champs qui seront indexes en fulltext
* @param string $keys Tableau des champs cles noms => valeur * @param string $keys Tableau des champs cles noms => valeur
* @return int <0 if KO, >=0 if OK * @return int <0 if KO, >=0 if OK
*/ */
function DDLCreateTable($table, $fields, $primary_key, $type, $unique_keys = "", $fulltext_keys = "", $keys = ""); function DDLCreateTable($table, $fields, $primary_key, $type, $unique_keys = "", $fulltext_keys = "", $keys = "");
/** /**
* 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();
/** /**
* Create a new field into table * Create a new field into table
* *
* @param string $table Name of table * @param string $table Name of table
* @param string $field_name Name of field to add * @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_desc Tableau associatif de description du champ a inserer[nom du parametre][valeur du parametre]
* @param string $field_position Optionnel ex.: "after champtruc" * @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 = "");
/** /**
* Drop a field from table * Drop a field from table
* *
* @param string $table Name of table * @param string $table Name of table
* @param string $field_name Name of field to drop * @param string $field_name Name of field to drop
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function DDLDropField($table, $field_name); function DDLDropField($table, $field_name);
/** /**
* Update format of a field into a table * Update format of a field into a table
* *
* @param string $table Name of table * @param string $table Name of table
* @param string $field_name Name of field to modify * @param string $field_name Name of field to modify
* @param string $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);
/** /**
* Return list of available collation that can be used for database * Return list of available collation that can be used for database
* *
* @return array List of Collation * @return array List of Collation
*/ */
function getListOfCollation(); function getListOfCollation();
/** /**
* Return a pointer of line with description of a table or field * Return a pointer of line with description of a table or field
* *
* @param string $table Name of table * @param string $table Name of table
* @param string $field Optionnel : Name of field if we want description of field * @param string $field Optionnel : Name of field if we want description of field
* @return resource Resource * @return resource Resource
*/ */
function DDLDescTable($table, $field = ""); function DDLDescTable($table, $field = "");
/** /**
* Return version of database server * Return version of database server
* *
* @return string Version string * @return string Version string
*/ */
function getVersion(); function getVersion();
/** /**
* 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();
/** /**
* 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 string $dolibarr_main_db_host Ip serveur * @param string $dolibarr_main_db_host Ip serveur
* @param string $dolibarr_main_db_user Nom user a creer * @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_pass Mot de passe user a creer
* @param string $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 if KO, >=0 if OK * @return int <0 if KO, >=0 if OK
*/ */
function DDLCreateUser( function DDLCreateUser(
$dolibarr_main_db_host, $dolibarr_main_db_host,
@ -382,85 +382,85 @@ interface Database
); );
/** /**
* Convert (by PHP) a PHP server TZ string date into a Timestamps date (GMT if gm=true) * 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 -> 3600 with TZ+1 and gmt=0
* 19700101020000 -> 7200 whaterver is TZ if gmt=1 * 19700101020000 -> 7200 whaterver is TZ if gmt=1
* *
* @param string $string Date in a string (YYYYMMDDHHMMSS, YYYYMMDD, YYYY-MM-DD HH:MM:SS) * @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 int $gm 1=Input informations are GMT values, otherwise local to server TZ
* @return timestamp|string Date TMS * @return int|string Date TMS or ''
*/ */
function jdate($string, $gm=false); function jdate($string, $gm=false);
/** /**
* 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 string $fieldorvalue Field name or value to encrypt * @param string $fieldorvalue Field name or value to encrypt
* @param int $withQuotes Return string with quotes * @param int $withQuotes Return string with quotes
* @return string XXX(field) or XXX('value') or field or 'value' * @return string XXX(field) or XXX('value') or field or 'value'
*/ */
function encrypt($fieldorvalue, $withQuotes = 0); function encrypt($fieldorvalue, $withQuotes = 0);
/** /**
* Validate a database transaction * Validate a database transaction
* *
* @param string $log Add more log to default log line * @param string $log Add more log to default log line
* @return int 1 if validation is OK or transaction level no started, 0 if ERROR * @return int 1 if validation is OK or transaction level no started, 0 if ERROR
*/ */
function commit($log = ''); function commit($log = '');
/** /**
* List information of columns into a table. * List information of columns into a table.
* *
* @param string $table Name of table * @param string $table Name of table
* @return array Tableau des informations des champs de la table * @return array Array with inforation on table
*/ */
function DDLInfoTable($table); function DDLInfoTable($table);
/** /**
* Free last resultset used. * Free last resultset used.
* *
* @param resource $resultset Curseur de la requete voulue * @param resource $resultset Fre cursor
* @return void * @return void
*/ */
function free($resultset = 0); function free($resultset = 0);
/** /**
* Close database connexion * Close database connexion
* *
* @return boolean True if disconnect successfull, false otherwise * @return boolean True if disconnect successfull, false otherwise
* @see connect * @see connect
*/ */
function close(); function close();
/** /**
* Return last query in error * Return last query in error
* *
* @return string lastqueryerror * @return string lastqueryerror
*/ */
function lastqueryerror(); function lastqueryerror();
/** /**
* Return connexion ID * Return connexion ID
* *
* @return string Id connexion * @return string Id connexion
*/ */
function DDLGetConnectId(); function DDLGetConnectId();
/** /**
* Renvoie la ligne courante (comme un objet) pour le curseur resultset * Renvoie la ligne courante (comme un objet) pour le curseur resultset
* *
* @param resource $resultset Curseur de la requete voulue * @param resource $resultset Curseur de la requete voulue
* @return Object Object result line or false if KO or end of cursor * @return Object Object result line or false if KO or end of cursor
*/ */
function fetch_object($resultset); function fetch_object($resultset);
/** /**
* Select a database * Select a database
* *
* @param string $database Name of database * @param string $database Name of database
* @return boolean true if OK, false if KO * @return boolean true if OK, false if KO
*/ */
function select_db($database); function select_db($database);

View File

@ -82,7 +82,7 @@ abstract class DoliDB implements Database
* Convert (by PHP) a GM Timestamp date into a string date with PHP server TZ to insert into a date field. * Convert (by PHP) a GM Timestamp date into a string date with PHP server TZ to insert into a date field.
* Function to use to build INSERT, UPDATE or WHERE predica * Function to use to build INSERT, UPDATE or WHERE predica
* *
* @param string $param Date TMS to convert * @param int $param Date TMS to convert
* @return string Date in a string YYYYMMDDHHMMSS * @return string Date in a string YYYYMMDDHHMMSS
*/ */
function idate($param) function idate($param)
@ -271,7 +271,7 @@ abstract class DoliDB implements Database
* *
* @param string $string Date in a string (YYYYMMDDHHMMSS, YYYYMMDD, YYYY-MM-DD HH:MM:SS) * @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 int $gm 1=Input informations are GMT values, otherwise local to server TZ
* @return int|string Date TMS * @return int|string Date TMS or ''
*/ */
function jdate($string, $gm=false) function jdate($string, $gm=false)
{ {