dolibarr  7.0.0-beta
Public Member Functions | List of all members
DoliDB Class Reference

Class to manage Dolibarr database access. More...

+ Inheritance diagram for DoliDB:
+ Collaboration diagram for DoliDB:

Public Member Functions

 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...
 
- Public Member Functions inherited from Database
 fetch_row ($resultset)
 Return datas as an array. 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...
 
 affected_rows ($resultset)
 Renvoie le nombre de lignes dans le resultat d'une requete INSERT, DELETE ou UPDATE. More...
 
 error ()
 Return description of last error. More...
 
 DDLListTables ($database, $table= '')
 List tables into a database. More...
 
 decrypt ($value)
 Decrypt sensitive data in database. More...
 
 fetch_array ($resultset)
 Return datas as an array. More...
 
 escape ($stringtoencode)
 Escape a string to insert data. More...
 
 last_insert_id ($tab, $fieldid= 'rowid')
 Get last ID after an insert INSERT. More...
 
 getPathOfRestore ()
 Return full path of restore program. More...
 
 query ($query, $usesavepoint=0, $type= 'auto')
 Execute a SQL request and return the resultset. More...
 
 connect ($host, $login, $passwd, $name, $port=0)
 Connexion to server. 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...
 
 encrypt ($fieldorvalue, $withQuotes=0)
 Encrypt sensitive data in database Warning: This function includes the escape, so it must use direct value. More...
 
 DDLInfoTable ($table)
 List information of columns into a table. More...
 
 free ($resultset=null)
 Free last resultset used. More...
 
 close ()
 Close database connexion. More...
 
 DDLGetConnectId ()
 Return connexion ID. More...
 
 fetch_object ($resultset)
 Renvoie la ligne courante (comme un objet) pour le curseur resultset. More...
 
 select_db ($database)
 Select a database. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from Database
static convertSQLFromMysql ($line, $type= 'ddl')
 Convert a SQL request in Mysql syntax to native syntax. More...
 

Detailed Description

Class to manage Dolibarr database access.

Definition at line 30 of file DoliDB.class.php.

Member Function Documentation

DoliDB::begin ( )

Start transaction.

Returns
int 1 if transaction successfuly opened or already opened, 0 if error

Implements Database.

Definition at line 111 of file DoliDB.class.php.

References dol_syslog(), and Database\query().

DoliDB::commit (   $log = '')

Validate a database transaction.

Parameters
string$logAdd more log to default log line
Returns
int 1 if validation is OK or transaction level no started, 0 if ERROR

Implements Database.

Definition at line 138 of file DoliDB.class.php.

References dol_syslog(), and Database\query().

DoliDB::getVersionArray ( )

Return version of database server into an array.

Returns
array Version array

Implements Database.

Definition at line 206 of file DoliDB.class.php.

References Database\getVersion().

DoliDB::idate (   $param)

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

Parameters
int$paramDate TMS to convert
Returns
string Date in a string YYYY-MM-DD HH:MM:SS

Implements Database.

Definition at line 90 of file DoliDB.class.php.

References dol_print_date().

DoliDB::ifsql (   $test,
  $resok,
  $resko 
)

Format a SQL IF.

Parameters
string$testTest string (example: 'cd.statut=0', 'field IS NULL')
string$resokresultat si test egal
string$reskoresultat si test non egal
Returns
string SQL string

Implements Database.

Definition at line 78 of file DoliDB.class.php.

DoliDB::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.

Parameters
string$stringDate in a string (YYYYMMDDHHMMSS, YYYYMMDD, YYYY-MM-DD HH:MM:SS)
bool$gm1=Input informations are GMT values, otherwise local to server TZ
Returns
int|string Date TMS or ''

Implements Database.

Definition at line 281 of file DoliDB.class.php.

References dol_mktime().

DoliDB::lasterrno ( )

Return last error code.

Returns
string lasterrno

Implements Database.

Definition at line 101 of file DoliDB.class.php.

Referenced by DoliDBMssql\DDLCreateUser(), DoliDBMssql\errno(), DoliDBMysqli\query(), DoliDBMssql\query(), DoliDBSqlite3\query(), and DoliDBPgsql\query().

DoliDB::lasterror ( )

Return last error label.

Returns
string Last error

Implements Database.

Definition at line 267 of file DoliDB.class.php.

Referenced by DoliDBMssql\DDLDropField(), DoliDBPgsql\DDLDropField(), DoliDBMysqli\query(), DoliDBMssql\query(), DoliDBSqlite3\query(), and DoliDBPgsql\query().

DoliDB::lastquery ( )

Return last request executed with query()

Returns
string Last query

Implements Database.

Definition at line 216 of file DoliDB.class.php.

Referenced by DoliDBMysqli\query(), DoliDBMssql\query(), DoliDBSqlite3\query(), and DoliDBPgsql\query().

DoliDB::lastqueryerror ( )

Return last query in error.

Returns
string lastqueryerror

Implements Database.

Definition at line 296 of file DoliDB.class.php.

Referenced by DoliDBMysqli\query(), DoliDBMssql\query(), DoliDBSqlite3\query(), and DoliDBPgsql\query().

DoliDB::order (   $sortfield = null,
  $sortorder = null 
)

Define sort criteria of request.

Parameters
string$sortfieldList of sort fields, separated by comma. Example: 't1.fielda, t2.fieldb'
string$sortorderSort order, separated by comma. Example: 'ASC, DESC';
Returns
string String to provide syntax of a sort sql string

Implements Database.

Definition at line 228 of file DoliDB.class.php.

DoliDB::plimit (   $limit = 0,
  $offset = 0 
)

Define limits and offset of request.

Parameters
int$limitMaximum number of lines returned (-1=conf->liste_limit, 0=no limit)
int$offsetNumero of line from where starting fetch
Returns
string String with SQL syntax to add a limit and offset

Implements Database.

Definition at line 192 of file DoliDB.class.php.

DoliDB::rollback (   $log = '')

Annulation d'une transaction et retour aux anciennes valeurs.

Parameters
string$logAdd more log to default log line
Returns
resource|int 1 si annulation ok ou transaction non ouverte, 0 en cas d'erreur

Implements Database.

Definition at line 168 of file DoliDB.class.php.

References dol_syslog(), and Database\query().


The documentation for this class was generated from the following file: