dolibarr
9.0.0
|
Classe de gestion de la database de dolibarr. More...
Public Member Functions | |
__construct ($type, $host, $user, $pass, $name='', $port=0) | |
Constructor. More... | |
select_db ($database) | |
Select a database. More... | |
connect ($host, $login, $passwd, $name, $port=0) | |
Connexion to server. More... | |
getVersion () | |
Return version of database server. More... | |
getDriverInfo () | |
Return version of database client driver. More... | |
close () | |
Close database connexion. More... | |
begin () | |
Start transaction. More... | |
commit ($log='') | |
Validate a database transaction. More... | |
rollback ($log='') | |
Annulation d'une transaction et retour aux anciennes valeurs. More... | |
query ($query, $usesavepoint=0, $type='auto') | |
Execute a SQL request and return the resultset. More... | |
fetch_object ($resultset) | |
Renvoie la ligne courante (comme un objet) pour le curseur resultset. More... | |
fetch_array ($resultset) | |
Return datas as an array. More... | |
fetch_row ($resultset) | |
Return datas as an array. More... | |
num_rows ($resultset) | |
Return number of lines for result of a SELECT. More... | |
affected_rows ($resultset) | |
Renvoie le nombre de lignes dans le resultat d'une requete INSERT, DELETE ou UPDATE. More... | |
free ($resultset=null) | |
Free last resultset used. More... | |
escape ($stringtoencode) | |
Escape a string to insert data. More... | |
idate ($param) | |
Convert (by PHP) a GM Timestamp date into a PHP server TZ to insert into a date field. More... | |
errno () | |
Return generic error code of last operation. More... | |
error () | |
Return description of last error. More... | |
last_insert_id ($tab, $fieldid='rowid') | |
Get last ID after an insert INSERT. More... | |
encrypt ($fieldorvalue, $withQuotes=0) | |
Encrypt sensitive data in database Warning: This function includes the escape, so it must use direct value. More... | |
decrypt ($value) | |
Decrypt sensitive data in database. More... | |
DDLGetConnectId () | |
Return connexion ID. More... | |
DDLCreateDb ($database, $charset='', $collation='', $owner='') | |
Create a new database 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. More... | |
DDLListTables ($database, $table='') | |
List tables into a database. More... | |
DDLInfoTable ($table) | |
List information of columns into a table. More... | |
DDLCreateTable ($table, $fields, $primary_key, $type, $unique_keys=null, $fulltext_keys=null, $keys=null) | |
Create a table into database. More... | |
DDLDropTable ($table) | |
Drop a table into database. More... | |
DDLDescTable ($table, $field="") | |
Return a pointer of line with description of a table or field. More... | |
DDLAddField ($table, $field_name, $field_desc, $field_position="") | |
Create a new field into table. More... | |
DDLUpdateField ($table, $field_name, $field_desc) | |
Update format of a field into a table. More... | |
DDLDropField ($table, $field_name) | |
Drop a field from table. More... | |
DDLCreateUser ($dolibarr_main_db_host, $dolibarr_main_db_user, $dolibarr_main_db_pass, $dolibarr_main_db_name) | |
Create a user and privileges to connect to database (even if database does not exists yet) More... | |
getDefaultCharacterSetDatabase () | |
Return charset used to store data in database. More... | |
getListOfCharacterSet () | |
Return list of available charset that can be used to store data in database. More... | |
getDefaultCollationDatabase () | |
Return collation used in database. More... | |
getListOfCollation () | |
Return list of available collation that can be used for database. More... | |
getPathOfDump () | |
Return full path of dump program. More... | |
getPathOfRestore () | |
Return full path of restore program. More... | |
getServerParametersValues ($filter='') | |
Return value of server parameters. More... | |
getServerStatusValues ($filter='') | |
Return value of server status. More... | |
EscapeFieldName ($fieldname) | |
Escape a field name according to escape's syntax. More... | |
GetFieldInformation ($table, $fields) | |
Get information on field. More... | |
![]() | |
ifsql ($test, $resok, $resko) | |
Format a SQL IF. More... | |
idate ($param) | |
Convert (by PHP) a GM Timestamp date into a string date with PHP server TZ to insert into a date field. More... | |
lasterrno () | |
Return last error code. More... | |
begin () | |
Start transaction. More... | |
commit ($log='') | |
Validate a database transaction. More... | |
rollback ($log='') | |
Annulation d'une transaction et retour aux anciennes valeurs. More... | |
plimit ($limit=0, $offset=0) | |
Define limits and offset of request. More... | |
getVersionArray () | |
Return version of database server into an array. More... | |
lastquery () | |
Return last request executed with query() More... | |
order ($sortfield=null, $sortorder=null) | |
Define sort criteria of request. More... | |
lasterror () | |
Return last error label. More... | |
jdate ($string, $gm=false) | |
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. More... | |
lastqueryerror () | |
Return last query in error. More... | |
Static Public Member Functions | |
static | convertSQLFromMysql ($line, $type='ddl') |
Convert a SQL request in Mysql syntax to native syntax. More... | |
Public Attributes | |
$type ='mssql' | |
Database type. | |
const | LABEL ='MSSQL' |
Database label. | |
$forcecharset ='latin1' | |
Charset used to force charset when creating database. | |
$forcecollate ='latin1_swedish_ci' | |
Collate used to force collate when creating database. | |
const | VERSIONMIN ='2000' |
Version min database. | |
Classe de gestion de la database de dolibarr.
Definition at line 32 of file mssql.class.php.
DoliDBMssql::__construct | ( | $type, | |
$host, | |||
$user, | |||
$pass, | |||
$name = '' , |
|||
$port = 0 |
|||
) |
Constructor.
This create an opened connexion to a database server and eventually to a database
string | $type | Type of database (mysql, pgsql...) |
string | $host | Address of database server |
string | $user | Nom de l'utilisateur autorise |
string | $pass | Mot de passe |
string | $name | Nom de la database |
int | $port | Port of database server |
Definition at line 58 of file mssql.class.php.
DoliDBMssql::affected_rows | ( | $resultset | ) |
Renvoie le nombre de lignes dans le resultat d'une requete INSERT, DELETE ou UPDATE.
resource | $resultset | Curseur de la requete voulue |
Implements Database.
Definition at line 532 of file mssql.class.php.
DoliDBMssql::begin | ( | ) |
Start transaction.
Implements Database.
Definition at line 238 of file mssql.class.php.
DoliDBMssql::close | ( | ) |
Close database connexion.
Implements Database.
Definition at line 221 of file mssql.class.php.
DoliDBMssql::commit | ( | $log = '' | ) |
Validate a database transaction.
string | $log | Add more log to default log line |
Implements Database.
Definition at line 266 of file mssql.class.php.
DoliDBMssql::connect | ( | $host, | |
$login, | |||
$passwd, | |||
$name, | |||
$port = 0 |
|||
) |
Connexion to server.
string | $host | database server host |
string | $login | login |
string | $passwd | password |
string | $name | name of database (not used for mysql, used for pgsql) |
int | $port | Port of database server |
Implements Database.
Definition at line 166 of file mssql.class.php.
|
static |
Convert a SQL request in Mysql syntax to native syntax.
string | $line | SQL request line to convert |
string | $type | Type of SQL order ('ddl' for insert, update, select, delete or 'dml' for create, alter...) |
Implements Database.
Definition at line 137 of file mssql.class.php.
DoliDBMssql::DDLAddField | ( | $table, | |
$field_name, | |||
$field_desc, | |||
$field_position = "" |
|||
) |
Create a new field into table.
string | $table | Name of table |
string | $field_name | Name of field to add |
string | $field_desc | Tableau associatif de description du champ a inserer[nom du parametre][valeur du parametre] |
string | $field_position | Optionnel ex.: "after champtruc" |
Implements Database.
Definition at line 934 of file mssql.class.php.
DoliDBMssql::DDLCreateDb | ( | $database, | |
$charset = '' , |
|||
$collation = '' , |
|||
$owner = '' |
|||
) |
Create a new database 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.
string | $database | Database name to create |
string | $charset | Charset used to store data |
string | $collation | Charset used to sort data |
string | $owner | Username of database owner |
Implements Database.
Definition at line 747 of file mssql.class.php.
DoliDBMssql::DDLCreateTable | ( | $table, | |
$fields, | |||
$primary_key, | |||
$type, | |||
$unique_keys = null , |
|||
$fulltext_keys = null , |
|||
$keys = null |
|||
) |
Create a table into database.
string | $table | Nom de la table |
array | $fields | Tableau associatif [nom champ][tableau des descriptions] |
string | $primary_key | Nom du champ qui sera la clef primaire |
string | $type | Type de la table |
array | $unique_keys | Tableau associatifs Nom de champs qui seront clef unique => valeur |
array | $fulltext_keys | Tableau des Nom de champs qui seront indexes en fulltext |
array | $keys | Tableau des champs cles noms => valeur |
Implements Database.
Definition at line 820 of file mssql.class.php.
DoliDBMssql::DDLCreateUser | ( | $dolibarr_main_db_host, | |
$dolibarr_main_db_user, | |||
$dolibarr_main_db_pass, | |||
$dolibarr_main_db_name | |||
) |
Create a user and privileges to connect to database (even if database does not exists yet)
string | $dolibarr_main_db_host | Ip serveur |
string | $dolibarr_main_db_user | Nom user a creer |
string | $dolibarr_main_db_pass | Mot de passe user a creer |
string | $dolibarr_main_db_name | Database name where user must be granted |
Implements Database.
Definition at line 1018 of file mssql.class.php.
DoliDBMssql::DDLDescTable | ( | $table, | |
$field = "" |
|||
) |
Return a pointer of line with description of a table or field.
string | $table | Name of table |
string | $field | Optionnel : Name of field if we want description of field |
Implements Database.
Definition at line 914 of file mssql.class.php.
DoliDBMssql::DDLDropField | ( | $table, | |
$field_name | |||
) |
Drop a field from table.
string | $table | Name of table |
string | $field_name | Name of field to drop |
Implements Database.
Definition at line 995 of file mssql.class.php.
DoliDBMssql::DDLDropTable | ( | $table | ) |
Drop a table into database.
string | $table | Name of table |
Implements Database.
Definition at line 895 of file mssql.class.php.
DoliDBMssql::DDLGetConnectId | ( | ) |
Return connexion ID.
Implements Database.
Definition at line 723 of file mssql.class.php.
References $resql, fetch_row(), and query().
DoliDBMssql::DDLInfoTable | ( | $table | ) |
List information of columns into a table.
string | $table | Name of table |
Implements Database.
Definition at line 795 of file mssql.class.php.
DoliDBMssql::DDLListTables | ( | $database, | |
$table = '' |
|||
) |
List tables into a database.
string | $database | Name of database |
string | $table | Nmae of table filter ('xxx') |
Implements Database.
Definition at line 781 of file mssql.class.php.
DoliDBMssql::DDLUpdateField | ( | $table, | |
$field_name, | |||
$field_desc | |||
) |
Update format of a field into a table.
string | $table | Name of table |
string | $field_name | Name of field to modify |
string | $field_desc | Array with description of field format |
Implements Database.
Definition at line 971 of file mssql.class.php.
DoliDBMssql::decrypt | ( | $value | ) |
Decrypt sensitive data in database.
string | $value | Value to decrypt |
Implements Database.
Definition at line 702 of file mssql.class.php.
DoliDBMssql::encrypt | ( | $fieldorvalue, | |
$withQuotes = 0 |
|||
) |
Encrypt sensitive data in database Warning: This function includes the escape, so it must use direct value.
string | $fieldorvalue | Field name or value to encrypt |
int | $withQuotes | Return string with quotes |
Implements Database.
Definition at line 682 of file mssql.class.php.
DoliDBMssql::errno | ( | ) |
Return generic error code of last operation.
Implements Database.
Definition at line 588 of file mssql.class.php.
DoliDBMssql::error | ( | ) |
Return description of last error.
Implements Database.
Definition at line 641 of file mssql.class.php.
DoliDBMssql::escape | ( | $stringtoencode | ) |
Escape a string to insert data.
string | $stringtoencode | String to escape |
Implements Database.
Definition at line 565 of file mssql.class.php.
DoliDBMssql::EscapeFieldName | ( | $fieldname | ) |
Escape a field name according to escape's syntax.
string | $fieldname | Field's name to escape |
Definition at line 1176 of file mssql.class.php.
DoliDBMssql::fetch_array | ( | $resultset | ) |
Return datas as an array.
resource | $resultset | Resultset of request |
Implements Database.
Definition at line 484 of file mssql.class.php.
DoliDBMssql::fetch_object | ( | $resultset | ) |
Renvoie la ligne courante (comme un objet) pour le curseur resultset.
resource | $resultset | Curseur de la requete voulue |
Implements Database.
Definition at line 469 of file mssql.class.php.
DoliDBMssql::fetch_row | ( | $resultset | ) |
Return datas as an array.
resource | $resultset | Resultset of request |
Implements Database.
Definition at line 500 of file mssql.class.php.
Referenced by DDLGetConnectId().
DoliDBMssql::free | ( | $resultset = null | ) |
Free last resultset used.
resource | $resultset | Curseur de la requete voulue |
Implements Database.
Definition at line 551 of file mssql.class.php.
DoliDBMssql::getDefaultCharacterSetDatabase | ( | ) |
Return charset used to store data in database.
Implements Database.
Definition at line 1062 of file mssql.class.php.
DoliDBMssql::getDefaultCollationDatabase | ( | ) |
Return collation used in database.
Implements Database.
Definition at line 1088 of file mssql.class.php.
References $forcecollate, $resql, and query().
DoliDBMssql::getDriverInfo | ( | ) |
Return version of database client driver.
Implements Database.
Definition at line 210 of file mssql.class.php.
DoliDBMssql::GetFieldInformation | ( | $table, | |
$fields | |||
) |
Get information on field.
string | $table | Table name which contains fields |
mixed | $fields | String for one field or array of string for multiple field |
Definition at line 1191 of file mssql.class.php.
DoliDBMssql::getListOfCharacterSet | ( | ) |
Return list of available charset that can be used to store data in database.
Implements Database.
Definition at line 1075 of file mssql.class.php.
DoliDBMssql::getListOfCollation | ( | ) |
Return list of available collation that can be used for database.
Implements Database.
Definition at line 1104 of file mssql.class.php.
DoliDBMssql::getPathOfDump | ( | ) |
Return full path of dump program.
Implements Database.
Definition at line 1117 of file mssql.class.php.
DoliDBMssql::getPathOfRestore | ( | ) |
Return full path of restore program.
Implements Database.
Definition at line 1130 of file mssql.class.php.
DoliDBMssql::getServerParametersValues | ( | $filter = '' | ) |
Return value of server parameters.
string | $filter | Filter list on a particular value |
Implements Database.
Definition at line 1144 of file mssql.class.php.
DoliDBMssql::getServerStatusValues | ( | $filter = '' | ) |
Return value of server status.
string | $filter | Filter list on a particular value |
Implements Database.
Definition at line 1160 of file mssql.class.php.
DoliDBMssql::getVersion | ( | ) |
Return version of database server.
Implements Database.
Definition at line 194 of file mssql.class.php.
DoliDBMssql::idate | ( | $param | ) |
Convert (by PHP) a GM Timestamp date into a PHP server TZ to insert into a date field.
Function to use to build INSERT, UPDATE or WHERE predica
string | $param | Date TMS to convert |
Implements Database.
Definition at line 578 of file mssql.class.php.
DoliDBMssql::last_insert_id | ( | $tab, | |
$fieldid = 'rowid' |
|||
) |
Get last ID after an insert INSERT.
string | $tab | Table name concerned by insert. Ne sert pas sous MySql mais requis pour compatibilite avec Postgresql |
string | $fieldid | Field name |
Implements Database.
Definition at line 660 of file mssql.class.php.
DoliDBMssql::num_rows | ( | $resultset | ) |
Return number of lines for result of a SELECT.
resource | $resultset | Resulset of requests |
Implements Database.
Definition at line 516 of file mssql.class.php.
DoliDBMssql::query | ( | $query, | |
$usesavepoint = 0 , |
|||
$type = 'auto' |
|||
) |
Execute a SQL request and return the resultset.
string | $query | SQL query string |
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. |
string | $type | Type of SQL order ('ddl' for insert, update, select, delete or 'dml' for create, alter...) |
Implements Database.
Definition at line 327 of file mssql.class.php.
References $type.
Referenced by DDLGetConnectId(), getDefaultCollationDatabase(), and getVersion().
DoliDBMssql::rollback | ( | $log = '' | ) |
Annulation d'une transaction et retour aux anciennes valeurs.
string | $log | Add more log to default log line |
Implements Database.
Definition at line 299 of file mssql.class.php.
DoliDBMssql::select_db | ( | $database | ) |
Select a database.
string | $database | Name of database |
Implements Database.
Definition at line 149 of file mssql.class.php.