dolibarr 21.0.0-alpha
|
TraceableDB class. More...
Public Member Functions | |
__construct ($db) | |
Constructor. | |
ifsql ($test, $resok, $resko) | |
Format a SQL IF. | |
fetch_row ($resultset) | |
Return datas as an array. | |
idate ($param, $gm='tzserver') | |
Convert (by PHP) a GM Timestamp date into a string date with PHP server TZ to insert into a date field. | |
lasterrno () | |
Return last error code. | |
begin ($textinlog='') | |
Start transaction. | |
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. | |
getVersionArray () | |
Return version of database server into an array. | |
convertSQLFromMysql ($line, $type='ddl') | |
Convert a SQL request in Mysql syntax to native syntax. | |
affected_rows ($resultset) | |
Return the number o flines into the result of a request INSERT, DELETE or UPDATE. | |
error () | |
Return description of last error. | |
DDLListTables ($database, $table='') | |
List tables into a database. | |
DDLListTablesFull ($database, $table='') | |
List tables into a database with table info. | |
lastquery () | |
Return last request executed with query() | |
order ($sortfield=null, $sortorder=null) | |
Define sort criteria of request. | |
decrypt ($value) | |
Decrypt sensitive data in database. | |
fetch_array ($resultset) | |
Return datas as an array. | |
lasterror () | |
Return last error label. | |
escape ($stringtoencode) | |
Escape a string to insert data. | |
escapeforlike ($stringtoencode) | |
Escape a string to insert data into a like. | |
last_insert_id ($tab, $fieldid='rowid') | |
Get last ID after an insert INSERT. | |
getPathOfRestore () | |
Return full path of restore program. | |
rollback ($log='') | |
Cancel a transaction and go back to initial data values. | |
query ($query, $usesavepoint=0, $type='auto', $result_mode=0) | |
Execute a SQL request and return the resultset. | |
connect ($host, $login, $passwd, $name, $port=0) | |
Connection to server. | |
plimit ($limit=0, $offset=0) | |
Define limits and offset of request. | |
getServerParametersValues ($filter='') | |
Return value of server parameters. | |
getServerStatusValues ($filter='') | |
Return value of server status. | |
getDefaultCollationDatabase () | |
Return collation used in database. | |
num_rows ($resultset) | |
Return number of lines for result of a SELECT. | |
getPathOfDump () | |
Return full path of dump program. | |
getDriverInfo () | |
Return version of database client driver. | |
errno () | |
Return generic error code of last operation. | |
DDLCreateTable ($table, $fields, $primary_key, $type, $unique_keys=null, $fulltext_keys=null, $keys=null) | |
Create a table into database. | |
DDLDropTable ($table) | |
Drop a table into database. | |
getListOfCharacterSet () | |
Return list of available charset that can be used to store data in database. | |
DDLAddField ($table, $field_name, $field_desc, $field_position="") | |
Create a new field into table. | |
DDLDropField ($table, $field_name) | |
Drop a field from table. | |
DDLUpdateField ($table, $field_name, $field_desc) | |
Update format of a field into a table. | |
getListOfCollation () | |
Return list of available collation that can be used for database. | |
DDLDescTable ($table, $field="") | |
Return a pointer of line with description of a table or field. | |
getVersion () | |
Return version of database server. | |
getDefaultCharacterSetDatabase () | |
Return charset used to store data in database. | |
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) | |
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 whatever is TZ if gmt=1. | |
encrypt ($fieldorvalue, $withQuotes=1) | |
Encrypt sensitive data in database Warning: This function includes the escape and add the SQL simple quotes on strings. | |
commit ($log='') | |
Validate a database transaction. | |
DDLInfoTable ($table) | |
List information of columns into a table. | |
free ($resultset=null) | |
Free last resultset used. | |
close () | |
Close database connection. | |
lastqueryerror () | |
Return last query in error. | |
DDLGetConnectId () | |
Return connection ID. | |
fetch_object ($resultset) | |
Returns the current line (as an object) for the resultset cursor. | |
select_db ($database) | |
Select a database. | |
Public Member Functions inherited from DoliDB | |
prefix () | |
Return the DB prefix found into prefix_db (if it was set manually by doing $dbhandler->prefix_db=...). | |
stddevpop ($nameoffield) | |
Return SQL string to aggregate using the Standard Deviation of population. | |
hintindex ($nameofindex) | |
Return SQL string to force an index. | |
regexpsql ($subject, $pattern, $sqlstring=0) | |
Format a SQL REGEXP. | |
sanitize ($stringtosanitize, $allowsimplequote=0, $allowsequals=0, $allowsspace=0, $allowschars=1) | |
Sanitize a string for SQL forging. | |
getRow ($sql) | |
Return first result from query as object Note : This method executes a given SQL query and retrieves the first row of results as an object. | |
getRows ($sql) | |
Return all results from query as an array of objects. | |
Public Member Functions inherited from Database | |
sanitize ($stringtosanitize) | |
Sanitize a string for SQL forging. | |
Public Attributes | |
const | LABEL = '' |
@const Database label | |
const | VERSIONMIN = '' |
@const Version min database | |
Public Attributes inherited from DoliDB | |
const | VERSIONMIN = self::VERSIONMIN |
Force subclass to implement VERSIONMIN - required DB version. | |
const | LABEL = self::LABEL |
Force subclass to implement LABEL - description of DB type. | |
Protected Member Functions | |
startTracing () | |
Start query tracing. | |
endTracing ($sql, $resql) | |
End query tracing. | |
TraceableDB::__construct | ( | $db | ) |
TraceableDB::affected_rows | ( | $resultset | ) |
Return the number o flines into the result of a request INSERT, DELETE or UPDATE.
resource | $resultset | Curseur de la requete voulue |
Implements Database.
Definition at line 182 of file TraceableDB.php.
TraceableDB::begin | ( | $textinlog = '' | ) |
Start transaction.
string | $textinlog | Add a small text into log. '' by default. |
Reimplemented from DoliDB.
Definition at line 131 of file TraceableDB.php.
TraceableDB::close | ( | ) |
Close database connection.
Implements Database.
Definition at line 696 of file TraceableDB.php.
TraceableDB::commit | ( | $log = '' | ) |
Validate a database transaction.
string | $log | Add more log to default log line |
Reimplemented from DoliDB.
Definition at line 663 of file TraceableDB.php.
TraceableDB::connect | ( | $host, | |
$login, | |||
$passwd, | |||
$name, | |||
$port = 0 ) |
Connection 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 402 of file TraceableDB.php.
TraceableDB::convertSQLFromMysql | ( | $line, | |
$type = 'ddl' ) |
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 169 of file TraceableDB.php.
TraceableDB::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 |
array{type:string,label:string,enabled:int|string,position:int,notnull?:int,visible:int,noteditable?:int,default?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,csslist?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array<int,string>,comment?:string} | $field_desc Tableau associatif de description du champ a inserer[nom du parameter][valeur du parameter] | |
string | $field_position | Optionnel ex.: "after champtruc" |
Implements Database.
Definition at line 542 of file TraceableDB.php.
TraceableDB::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 147 of file TraceableDB.php.
TraceableDB::DDLCreateTable | ( | $table, | |
$fields, | |||
$primary_key, | |||
$type, | |||
$unique_keys = null, | |||
$fulltext_keys = null, | |||
$keys = null ) |
Create a table into database.
string | $table | Name of table |
array<string,array{type:string,label:string,enabled:int<0,2>|string,position:int,notnull?:int,visible:int<-2,5>|string,noteditable?:int<0,1>,default?:string,index?:int,foreignkey?:string,searchall?:int<0,1>,isameasure?:int<0,1>,css?:string,csslist?:string,help?:string,showoncombobox?:int<0,2>,disabled?:int<0,1>,arrayofkeyval?:array<int|string,string>,comment?:string,validate?:int<0,1>}> | $fields Associative table [field name][table of descriptions] | |
string | $primary_key | Nom du champ qui sera la clef primaire |
string | $type | Type de la table |
?array<string,mixed> | $unique_keys Tableau associatifs Nom de champs qui seront clef unique => valeur | |
string[] | $fulltext_keys | Tableau des Nom de champs qui seront indexes en fulltext |
string[] | $keys | Tableau des champs cles noms => valeur |
Implements Database.
Definition at line 507 of file TraceableDB.php.
TraceableDB::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 | Password user a creer |
string | $dolibarr_main_db_name | Database name where user must be granted |
Implements Database.
Definition at line 623 of file TraceableDB.php.
TraceableDB::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 589 of file TraceableDB.php.
TraceableDB::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 554 of file TraceableDB.php.
TraceableDB::DDLDropTable | ( | $table | ) |
Drop a table into database.
string | $table | Name of table |
Implements Database.
Definition at line 518 of file TraceableDB.php.
TraceableDB::DDLGetConnectId | ( | ) |
Return connection ID.
Implements Database.
Definition at line 716 of file TraceableDB.php.
TraceableDB::DDLInfoTable | ( | $table | ) |
List information of columns into a table.
string | $table | Name of table |
Implements Database.
Definition at line 674 of file TraceableDB.php.
TraceableDB::DDLListTables | ( | $database, | |
$table = '' ) |
List tables into a database.
string | $database | Name of database |
string | $table | Name of table filter ('xxx') |
Implements Database.
Definition at line 205 of file TraceableDB.php.
TraceableDB::DDLListTablesFull | ( | $database, | |
$table = '' ) |
List tables into a database with table info.
string | $database | Name of database |
string | $table | Name of table filter ('xxx') |
Implements Database.
Definition at line 217 of file TraceableDB.php.
TraceableDB::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 |
array{type:string,label:string,enabled:int|string,position:int,notnull?:int,visible:int,noteditable?:int,default?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,csslist?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array<int,string>,comment?:string} | $field_desc Array with description of field format |
Implements Database.
Definition at line 567 of file TraceableDB.php.
TraceableDB::decrypt | ( | $value | ) |
Decrypt sensitive data in database.
string | $value | Value to decrypt |
Implements Database.
Definition at line 250 of file TraceableDB.php.
TraceableDB::encrypt | ( | $fieldorvalue, | |
$withQuotes = 1 ) |
Encrypt sensitive data in database Warning: This function includes the escape and add the SQL simple quotes on strings.
string | $fieldorvalue | Field name or value to encrypt |
int | $withQuotes | Return string including the SQL simple quotes. This param must always be 1 (Value 0 is bugged and deprecated). |
Implements Database.
Definition at line 652 of file TraceableDB.php.
|
protected |
End query tracing.
string | $sql | query string |
string | $resql | query result |
Definition at line 374 of file TraceableDB.php.
Referenced by query().
TraceableDB::errno | ( | ) |
Return generic error code of last operation.
Implements Database.
Definition at line 490 of file TraceableDB.php.
TraceableDB::error | ( | ) |
Return description of last error.
Implements Database.
Definition at line 193 of file TraceableDB.php.
TraceableDB::escape | ( | $stringtoencode | ) |
Escape a string to insert data.
string | $stringtoencode | String to escape |
Implements Database.
Definition at line 284 of file TraceableDB.php.
TraceableDB::escapeforlike | ( | $stringtoencode | ) |
Escape a string to insert data into a like.
string | $stringtoencode | String to escape |
Implements Database.
Definition at line 295 of file TraceableDB.php.
TraceableDB::fetch_array | ( | $resultset | ) |
Return datas as an array.
resource | $resultset | Resultset of request |
Implements Database.
Definition at line 262 of file TraceableDB.php.
TraceableDB::fetch_object | ( | $resultset | ) |
Returns the current line (as an object) for the resultset cursor.
resource | PgSql\Connection | $resultset | Handler of the desired SQL request |
Implements Database.
Definition at line 728 of file TraceableDB.php.
TraceableDB::fetch_row | ( | $resultset | ) |
Return datas as an array.
resource | $resultset | Resultset of request |
Implements Database.
Definition at line 96 of file TraceableDB.php.
TraceableDB::free | ( | $resultset = null | ) |
Free last resultset used.
resource | $resultset | Fre cursor |
Implements Database.
Definition at line 685 of file TraceableDB.php.
TraceableDB::getDefaultCharacterSetDatabase | ( | ) |
Return charset used to store data in database.
Implements Database.
Definition at line 609 of file TraceableDB.php.
TraceableDB::getDefaultCollationDatabase | ( | ) |
Return collation used in database.
Implements Database.
Definition at line 446 of file TraceableDB.php.
TraceableDB::getDriverInfo | ( | ) |
Return version of database client driver.
Implements Database.
Definition at line 480 of file TraceableDB.php.
TraceableDB::getListOfCharacterSet | ( | ) |
Return list of available charset that can be used to store data in database.
Implements Database.
Definition at line 528 of file TraceableDB.php.
TraceableDB::getListOfCollation | ( | ) |
Return list of available collation that can be used for database.
Implements Database.
Definition at line 577 of file TraceableDB.php.
TraceableDB::getPathOfDump | ( | ) |
Return full path of dump program.
Implements Database.
Definition at line 470 of file TraceableDB.php.
TraceableDB::getPathOfRestore | ( | ) |
Return full path of restore program.
Implements Database.
Definition at line 319 of file TraceableDB.php.
TraceableDB::getServerParametersValues | ( | $filter = '' | ) |
Return value of server parameters.
string | $filter | Filter list on a particular value |
Implements Database.
Definition at line 425 of file TraceableDB.php.
TraceableDB::getServerStatusValues | ( | $filter = '' | ) |
Return value of server status.
string | $filter | Filter list on a particular value |
Implements Database.
Definition at line 436 of file TraceableDB.php.
TraceableDB::getVersion | ( | ) |
Return version of database server.
Implements Database.
Definition at line 599 of file TraceableDB.php.
TraceableDB::getVersionArray | ( | ) |
Return version of database server into an array.
Reimplemented from DoliDB.
Definition at line 157 of file TraceableDB.php.
TraceableDB::idate | ( | $param, | |
$gm = 'tzserver' ) |
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
int | $param | Date TMS to convert |
'gmt'|'tzserver' | $gm 'gmt'=Input information are GMT values, 'tzserver'=Local to server TZ |
Reimplemented from DoliDB.
Definition at line 110 of file TraceableDB.php.
TraceableDB::ifsql | ( | $test, | |
$resok, | |||
$resko ) |
Format a SQL IF.
string | $test | Test string (example: 'cd.statut=0', 'field IS NULL') |
string | $resok | resultat si test equal |
string | $resko | resultat si test non equal |
Reimplemented from DoliDB.
Definition at line 84 of file TraceableDB.php.
TraceableDB::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 whatever is TZ if gmt=1.
string | $string | Date in a string (YYYYMMDDHHMMSS, YYYYMMDD, YYYY-MM-DD HH:MM:SS) |
bool | $gm | 1=Input information are GMT values, otherwise local to server TZ |
Reimplemented from DoliDB.
Definition at line 638 of file TraceableDB.php.
TraceableDB::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 308 of file TraceableDB.php.
TraceableDB::lasterrno | ( | ) |
Return last error code.
Reimplemented from DoliDB.
Definition at line 120 of file TraceableDB.php.
TraceableDB::lasterror | ( | ) |
Return last error label.
Reimplemented from DoliDB.
Definition at line 273 of file TraceableDB.php.
TraceableDB::lastquery | ( | ) |
Return last request executed with query()
Reimplemented from DoliDB.
Definition at line 227 of file TraceableDB.php.
TraceableDB::lastqueryerror | ( | ) |
Return last query in error.
Reimplemented from DoliDB.
Definition at line 706 of file TraceableDB.php.
TraceableDB::num_rows | ( | $resultset | ) |
Return number of lines for result of a SELECT.
resource | $resultset | Resulset of requests |
Implements Database.
Definition at line 459 of file TraceableDB.php.
TraceableDB::order | ( | $sortfield = null, | |
$sortorder = null ) |
Define sort criteria of request.
string | $sortfield | List of sort fields |
string | $sortorder | Sort order |
Reimplemented from DoliDB.
Definition at line 239 of file TraceableDB.php.
TraceableDB::plimit | ( | $limit = 0, | |
$offset = 0 ) |
Define limits and offset of request.
int | $limit | Maximum number of lines returned (-1=conf->liste_limit, 0=no limit) |
int | $offset | Numero of line from where starting fetch |
Reimplemented from DoliDB.
Definition at line 414 of file TraceableDB.php.
TraceableDB::query | ( | $query, | |
$usesavepoint = 0, | |||
$type = 'auto', | |||
$result_mode = 0 ) |
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 rollback 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...) |
int | $result_mode | Result mode |
Implements Database.
Definition at line 345 of file TraceableDB.php.
References endTracing(), and startTracing().
TraceableDB::rollback | ( | $log = '' | ) |
Cancel a transaction and go back to initial data values.
string | $log | Add more log to default log line |
Reimplemented from DoliDB.
Definition at line 330 of file TraceableDB.php.
TraceableDB::select_db | ( | $database | ) |
Select a database.
string | $database | Name of database |
Implements Database.
Definition at line 741 of file TraceableDB.php.
|
protected |
Start query tracing.
Definition at line 361 of file TraceableDB.php.
Referenced by query().