|
dolibarr 18.0.8
|
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. | |
| 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) | |
| Connexion 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 whaterver 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 connexion. | |
| lastqueryerror () | |
| Return last query in error. | |
| DDLGetConnectId () | |
| Return connexion 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=...). | |
| hintindex ($nameofindex) | |
| Return SQL string to force an index. | |
| regexpsql ($subject, $pattern, $sqlstring=false) | |
| Format a SQL REGEXP. | |
| sanitize ($stringtosanitize, $allowsimplequote=0, $allowsequals=0, $allowsspace=0) | |
| 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 Note : This method executes a given SQL query and retrieves all row of results as an array of objects. | |
Public Member Functions inherited from Database | |
| idate ($param) | |
| Convert (by PHP) a GM Timestamp date into a string date with PHP server TZ to insert into a date field. | |
| sanitize ($stringtosanitize) | |
| Sanitize a string for SQL forging. | |
Static Public Member Functions | |
| static | convertSQLFromMysql ($line, $type='ddl') |
| Convert a SQL request in Mysql syntax to native syntax. | |
Public Attributes | |
| const | LABEL = '' |
| @const Database label | |
| const | VERSIONMIN = '' |
| @const Version min database | |
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 180 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 129 of file TraceableDB.php.
| TraceableDB::close | ( | ) |
Close database connexion.
Implements Database.
Definition at line 694 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 661 of file TraceableDB.php.
| TraceableDB::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 400 of file TraceableDB.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 167 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 |
| 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 540 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 145 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 | $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 505 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 | Mot de passe user a creer |
| string | $dolibarr_main_db_name | Database name where user must be granted |
Implements Database.
Definition at line 621 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 587 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 552 of file TraceableDB.php.
| TraceableDB::DDLDropTable | ( | $table | ) |
Drop a table into database.
| string | $table | Name of table |
Implements Database.
Definition at line 516 of file TraceableDB.php.
| TraceableDB::DDLGetConnectId | ( | ) |
Return connexion ID.
Implements Database.
Definition at line 714 of file TraceableDB.php.
| TraceableDB::DDLInfoTable | ( | $table | ) |
List information of columns into a table.
| string | $table | Name of table |
Implements Database.
Definition at line 672 of file TraceableDB.php.
| TraceableDB::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 203 of file TraceableDB.php.
| TraceableDB::DDLListTablesFull | ( | $database, | |
| $table = '' ) |
List tables into a database with table info.
| string | $database | Name of database |
| string | $table | Nmae of table filter ('xxx') |
Implements Database.
Definition at line 215 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 |
| string | $field_desc | Array with description of field format |
Implements Database.
Definition at line 565 of file TraceableDB.php.
| TraceableDB::decrypt | ( | $value | ) |
Decrypt sensitive data in database.
| string | $value | Value to decrypt |
Implements Database.
Definition at line 248 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 650 of file TraceableDB.php.
|
protected |
End query tracing.
| string | $sql | query string |
| string | $resql | query result |
Definition at line 372 of file TraceableDB.php.
Referenced by query().
| TraceableDB::errno | ( | ) |
Return generic error code of last operation.
Implements Database.
Definition at line 488 of file TraceableDB.php.
| TraceableDB::error | ( | ) |
Return description of last error.
Implements Database.
Definition at line 191 of file TraceableDB.php.
| TraceableDB::escape | ( | $stringtoencode | ) |
Escape a string to insert data.
| string | $stringtoencode | String to escape |
Implements Database.
Definition at line 282 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 293 of file TraceableDB.php.
| TraceableDB::fetch_array | ( | $resultset | ) |
Return datas as an array.
| resource | $resultset | Resultset of request |
Implements Database.
Definition at line 260 of file TraceableDB.php.
| TraceableDB::fetch_object | ( | $resultset | ) |
Returns the current line (as an object) for the resultset cursor.
| resource | Connection | $resultset | Handler of the desired SQL request |
Implements Database.
Definition at line 726 of file TraceableDB.php.
| TraceableDB::fetch_row | ( | $resultset | ) |
Return datas as an array.
| resource | $resultset | Resultset of request |
Implements Database.
Definition at line 94 of file TraceableDB.php.
| TraceableDB::free | ( | $resultset = null | ) |
Free last resultset used.
| resource | $resultset | Fre cursor |
Implements Database.
Definition at line 683 of file TraceableDB.php.
| TraceableDB::getDefaultCharacterSetDatabase | ( | ) |
Return charset used to store data in database.
Implements Database.
Definition at line 607 of file TraceableDB.php.
| TraceableDB::getDefaultCollationDatabase | ( | ) |
Return collation used in database.
Implements Database.
Definition at line 444 of file TraceableDB.php.
| TraceableDB::getDriverInfo | ( | ) |
Return version of database client driver.
Implements Database.
Definition at line 478 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 526 of file TraceableDB.php.
| TraceableDB::getListOfCollation | ( | ) |
Return list of available collation that can be used for database.
Implements Database.
Definition at line 575 of file TraceableDB.php.
| TraceableDB::getPathOfDump | ( | ) |
Return full path of dump program.
Implements Database.
Definition at line 468 of file TraceableDB.php.
| TraceableDB::getPathOfRestore | ( | ) |
Return full path of restore program.
Implements Database.
Definition at line 317 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 423 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 434 of file TraceableDB.php.
| TraceableDB::getVersion | ( | ) |
Return version of database server.
Implements Database.
Definition at line 597 of file TraceableDB.php.
| TraceableDB::getVersionArray | ( | ) |
Return version of database server into an array.
Reimplemented from DoliDB.
Definition at line 155 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 |
| mixed | $gm | 'gmt'=Input informations are GMT values, 'tzserver'=Local to server TZ |
Reimplemented from DoliDB.
Definition at line 108 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 egal |
| string | $resko | resultat si test non egal |
Reimplemented from DoliDB.
Definition at line 82 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 whaterver is TZ if gmt=1.
| string | $string | Date in a string (YYYYMMDDHHMMSS, YYYYMMDD, YYYY-MM-DD HH:MM:SS) |
| bool | $gm | 1=Input informations are GMT values, otherwise local to server TZ |
Reimplemented from DoliDB.
Definition at line 636 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 306 of file TraceableDB.php.
| TraceableDB::lasterrno | ( | ) |
Return last error code.
Reimplemented from DoliDB.
Definition at line 118 of file TraceableDB.php.
| TraceableDB::lasterror | ( | ) |
Return last error label.
Reimplemented from DoliDB.
Definition at line 271 of file TraceableDB.php.
| TraceableDB::lastquery | ( | ) |
Return last request executed with query()
Reimplemented from DoliDB.
Definition at line 225 of file TraceableDB.php.
| TraceableDB::lastqueryerror | ( | ) |
Return last query in error.
Reimplemented from DoliDB.
Definition at line 704 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 457 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 237 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 412 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 343 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 328 of file TraceableDB.php.
| TraceableDB::select_db | ( | $database | ) |
Select a database.
| string | $database | Name of database |
Implements Database.
Definition at line 739 of file TraceableDB.php.
|
protected |
Start query tracing.
Definition at line 359 of file TraceableDB.php.
Referenced by query().