dolibarr
x.y.z
|
TraceableDB class. More...
Public Member Functions | |
__construct ($db) | |
Constructor. More... | |
ifsql ($test, $resok, $resko) | |
Format a SQL IF. More... | |
fetch_row ($resultset) | |
Return datas as an array. More... | |
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. More... | |
lasterrno () | |
Return last error code. More... | |
begin ($textinlog='') | |
Start transaction. 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... | |
getVersionArray () | |
Return version of database server into an array. More... | |
affected_rows ($resultset) | |
Return the number o flines into the result of a request INSERT, DELETE or UPDATE. More... | |
error () | |
Return description of last error. More... | |
DDLListTables ($database, $table='') | |
List tables into a database. More... | |
lastquery () | |
Return last request executed with query() More... | |
order ($sortfield=null, $sortorder=null) | |
Define sort criteria of request. More... | |
decrypt ($value) | |
Decrypt sensitive data in database. More... | |
fetch_array ($resultset) | |
Return datas as an array. More... | |
lasterror () | |
Return last error label. More... | |
escape ($stringtoencode) | |
Escape a string to insert data. More... | |
escapeforlike ($stringtoencode) | |
Escape a string to insert data into a like. More... | |
last_insert_id ($tab, $fieldid='rowid') | |
Get last ID after an insert INSERT. More... | |
getPathOfRestore () | |
Return full path of restore program. More... | |
rollback ($log='') | |
Cancel a transaction and go back to initial data values. More... | |
query ($query, $usesavepoint=0, $type='auto', $result_mode=0) | |
Execute a SQL request and return the resultset. More... | |
connect ($host, $login, $passwd, $name, $port=0) | |
Connexion to server. More... | |
plimit ($limit=0, $offset=0) | |
Define limits and offset of request. More... | |
getServerParametersValues ($filter='') | |
Return value of server parameters. More... | |
getServerStatusValues ($filter='') | |
Return value of server status. More... | |
getDefaultCollationDatabase () | |
Return collation used in database. More... | |
num_rows ($resultset) | |
Return number of lines for result of a SELECT. More... | |
getPathOfDump () | |
Return full path of dump program. More... | |
getDriverInfo () | |
Return version of database client driver. More... | |
errno () | |
Return generic error code of last operation. 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... | |
getListOfCharacterSet () | |
Return list of available charset that can be used to store data in database. More... | |
DDLAddField ($table, $field_name, $field_desc, $field_position="") | |
Create a new field into table. More... | |
DDLDropField ($table, $field_name) | |
Drop a field from table. More... | |
DDLUpdateField ($table, $field_name, $field_desc) | |
Update format of a field into a table. More... | |
getListOfCollation () | |
Return list of available collation that can be used for database. More... | |
DDLDescTable ($table, $field="") | |
Return a pointer of line with description of a table or field. More... | |
getVersion () | |
Return version of database server. More... | |
getDefaultCharacterSetDatabase () | |
Return charset used to store data in database. 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... | |
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... | |
encrypt ($fieldorvalue, $withQuotes=1) | |
Encrypt sensitive data in database Warning: This function includes the escape and add the SQL simple quotes on strings. More... | |
commit ($log='') | |
Validate a database transaction. More... | |
DDLInfoTable ($table) | |
List information of columns into a table. More... | |
free ($resultset=null) | |
Free last resultset used. More... | |
close () | |
Close database connexion. More... | |
lastqueryerror () | |
Return last query in error. More... | |
DDLGetConnectId () | |
Return connexion ID. More... | |
fetch_object ($resultset) | |
Returns the current line (as an object) for the resultset cursor. More... | |
select_db ($database) | |
Select a database. More... | |
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=...). More... | |
hintindex ($nameofindex) | |
Return SQL string to force an index. More... | |
regexpsql ($subject, $pattern, $sqlstring=false) | |
Format a SQL REGEXP. More... | |
sanitize ($stringtosanitize, $allowsimplequote=0, $allowsequals=0) | |
Sanitize a string for SQL forging. More... | |
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. More... | |
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. More... | |
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. More... | |
sanitize ($stringtosanitize) | |
Sanitize a string for SQL forging. More... | |
Static Public Member Functions | |
static | convertSQLFromMysql ($line, $type='ddl') |
Convert a SQL request in Mysql syntax to native syntax. More... | |
Public Attributes | |
const | LABEL = '' |
@const Database label | |
const | VERSIONMIN = '' |
@const Version min database | |
Protected Member Functions | |
startTracing () | |
Start query tracing. More... | |
endTracing ($sql, $resql) | |
End query tracing. More... | |
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 159 of file TraceableDB.php.
References db.
TraceableDB::begin | ( | $textinlog = '' | ) |
Start transaction.
string | $textinlog | Add a small text into log. '' by default. |
Reimplemented from DoliDB.
Definition at line 108 of file TraceableDB.php.
References db.
TraceableDB::close | ( | ) |
Close database connexion.
Implements Database.
Definition at line 661 of file TraceableDB.php.
References db.
TraceableDB::commit | ( | $log = '' | ) |
Validate a database transaction.
string | $log | Add more log to default log line |
Reimplemented from DoliDB.
Definition at line 628 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 367 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 146 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 507 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 124 of file TraceableDB.php.
References db.
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 472 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 588 of file TraceableDB.php.
References db.
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 554 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 519 of file TraceableDB.php.
TraceableDB::DDLDropTable | ( | $table | ) |
Drop a table into database.
string | $table | Name of table |
Implements Database.
Definition at line 483 of file TraceableDB.php.
TraceableDB::DDLGetConnectId | ( | ) |
Return connexion ID.
Implements Database.
Definition at line 681 of file TraceableDB.php.
References db.
TraceableDB::DDLInfoTable | ( | $table | ) |
List information of columns into a table.
string | $table | Name of table |
Implements Database.
Definition at line 639 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 182 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 532 of file TraceableDB.php.
TraceableDB::decrypt | ( | $value | ) |
Decrypt sensitive data in database.
string | $value | Value to decrypt |
Implements Database.
Definition at line 215 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 617 of file TraceableDB.php.
References db.
|
protected |
End query tracing.
string | $sql | query string |
string | $resql | query result |
Definition at line 339 of file TraceableDB.php.
Referenced by query().
TraceableDB::errno | ( | ) |
Return generic error code of last operation.
Implements Database.
Definition at line 455 of file TraceableDB.php.
References db.
TraceableDB::error | ( | ) |
Return description of last error.
Implements Database.
Definition at line 170 of file TraceableDB.php.
References db.
TraceableDB::escape | ( | $stringtoencode | ) |
Escape a string to insert data.
string | $stringtoencode | String to escape |
Implements Database.
Definition at line 249 of file TraceableDB.php.
References db.
TraceableDB::escapeforlike | ( | $stringtoencode | ) |
Escape a string to insert data into a like.
string | $stringtoencode | String to escape |
Implements Database.
Definition at line 260 of file TraceableDB.php.
TraceableDB::fetch_array | ( | $resultset | ) |
Return datas as an array.
resource | $resultset | Resultset of request |
Implements Database.
Definition at line 227 of file TraceableDB.php.
References db.
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 693 of file TraceableDB.php.
References db.
TraceableDB::fetch_row | ( | $resultset | ) |
Return datas as an array.
resource | $resultset | Resultset of request |
Implements Database.
Definition at line 73 of file TraceableDB.php.
References db.
TraceableDB::free | ( | $resultset = null | ) |
Free last resultset used.
resource | $resultset | Fre cursor |
Implements Database.
Definition at line 650 of file TraceableDB.php.
References db.
TraceableDB::getDefaultCharacterSetDatabase | ( | ) |
Return charset used to store data in database.
Implements Database.
Definition at line 574 of file TraceableDB.php.
References db.
TraceableDB::getDefaultCollationDatabase | ( | ) |
Return collation used in database.
Implements Database.
Definition at line 411 of file TraceableDB.php.
References db.
TraceableDB::getDriverInfo | ( | ) |
Return version of database client driver.
Implements Database.
Definition at line 445 of file TraceableDB.php.
References db.
TraceableDB::getListOfCharacterSet | ( | ) |
Return list of available charset that can be used to store data in database.
Implements Database.
Definition at line 493 of file TraceableDB.php.
References db.
TraceableDB::getListOfCollation | ( | ) |
Return list of available collation that can be used for database.
Implements Database.
Definition at line 542 of file TraceableDB.php.
References db.
TraceableDB::getPathOfDump | ( | ) |
Return full path of dump program.
Implements Database.
Definition at line 435 of file TraceableDB.php.
References db.
TraceableDB::getPathOfRestore | ( | ) |
Return full path of restore program.
Implements Database.
Definition at line 284 of file TraceableDB.php.
References db.
TraceableDB::getServerParametersValues | ( | $filter = '' | ) |
Return value of server parameters.
string | $filter | Filter list on a particular value |
Implements Database.
Definition at line 390 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 401 of file TraceableDB.php.
TraceableDB::getVersion | ( | ) |
Return version of database server.
Implements Database.
Definition at line 564 of file TraceableDB.php.
References db.
TraceableDB::getVersionArray | ( | ) |
Return version of database server into an array.
Reimplemented from DoliDB.
Definition at line 134 of file TraceableDB.php.
References db.
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 87 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 61 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 603 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 273 of file TraceableDB.php.
TraceableDB::lasterrno | ( | ) |
Return last error code.
Reimplemented from DoliDB.
Definition at line 97 of file TraceableDB.php.
References db.
TraceableDB::lasterror | ( | ) |
Return last error label.
Reimplemented from DoliDB.
Definition at line 238 of file TraceableDB.php.
References db.
TraceableDB::lastquery | ( | ) |
Return last request executed with query()
Reimplemented from DoliDB.
Definition at line 192 of file TraceableDB.php.
References db.
TraceableDB::lastqueryerror | ( | ) |
Return last query in error.
Reimplemented from DoliDB.
Definition at line 671 of file TraceableDB.php.
References db.
TraceableDB::num_rows | ( | $resultset | ) |
Return number of lines for result of a SELECT.
resource | $resultset | Resulset of requests |
Implements Database.
Definition at line 424 of file TraceableDB.php.
References db.
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 204 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 379 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 310 of file TraceableDB.php.
References $resql, db, 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 295 of file TraceableDB.php.
TraceableDB::select_db | ( | $database | ) |
Select a database.
string | $database | Name of database |
Implements Database.
Definition at line 706 of file TraceableDB.php.
References db.
|
protected |
Start query tracing.
Definition at line 326 of file TraceableDB.php.
Referenced by query().