class DoliDBMysqli extends DoliDB (View source)

Class to manage Dolibarr database access for a MySQL database using the MySQLi extension

Constants

VERSIONMIN

LABEL

Properties

mysqli $db
$type
string $forcecharset from  DoliDB
string $forcecollate from  DoliDB
bool $connected from  DoliDB
bool $database_selected from  DoliDB
string $database_name from  DoliDB
string $database_user from  DoliDB
string $database_host from  DoliDB
int $database_port from  DoliDB
int $transaction_opened from  DoliDB
string $lastquery from  DoliDB
string $lastqueryerror from  DoliDB
string $lasterror from  DoliDB
string $lasterrno from  DoliDB
string $prefix_db from  DoliDB
bool $ok from  DoliDB
string $error from  DoliDB

Methods

string
prefix()

Return the DB prefix found into prefix_db (if it was set manually by doing $dbhandler->prefix_db=...).

from  DoliDB
string
ifsql(string $test, string $resok, string $resko)

Format a SQL IF

from  DoliDB
string
stddevpop(string $nameoffield)

Return SQL string to aggregate using the Standard Deviation of population

from  DoliDB
string
hintindex(string $nameofindex, int $mode = 1)

Return SQL string to force an index

string
regexpsql(string $subject, string $pattern, int $sqlstring = 0)

Format a SQL REGEXP

from  DoliDB
string
idate(int $param, "gmt"|"tzserver" $gm = 'tzserver')

Convert (by PHP) a GM Timestamp date into a string date with PHP server TZ to insert into a date field.

from  DoliDB
string
lasterrno()

Return last error code

from  DoliDB
string
sanitize(string $stringtosanitize, int $allowsimplequote = 0, int $allowsequals = 0, int $allowsspace = 0, int $allowschars = 1)

Sanitize a string for SQL forging

from  DoliDB
int
begin(string $textinlog = '')

Start transaction

from  DoliDB
int
commit(string $log = '')

Validate a database transaction

from  DoliDB
int
rollback(string $log = '')

Cancel a transaction and go back to initial data values

from  DoliDB
string
plimit(int $limit = 0, int $offset = 0)

Define limits and offset of request

from  DoliDB
string[]
getVersionArray()

Return version of database server into an array

from  DoliDB
string
lastquery()

Return last request executed with query()

from  DoliDB
string
order(string $sortfield = '', string $sortorder = '')

Define sort criteria of request

from  DoliDB
string
lasterror()

Return last error label

from  DoliDB
int|""
jdate(string $string, bool $gm = 'tzserver')

Convert (by PHP) a PHP server TZ string date into a Timestamps date (GMT if gm=true) 19700101020000 -> 3600 with server TZ = +1 and $gm='tzserver' 19700101020000 -> 7200 whatever is server TZ if $gm='gmt'

from  DoliDB
string
lastqueryerror()

Return last query in error

from  DoliDB
bool|int|object
getRow(string $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. It should only be used with SELECT queries Don't add LIMIT to your query, it will be added by this method

from  DoliDB
false|object[]
getRows(string $sql)

Return all results from query as an array of objects. Using this is a bad practice and is discouraged.

from  DoliDB
int
getNextAutoIncrementId(string $table)

Get the last ID of an auto-increment field of a table

mixed
prepare(string $sql)

Prepare a SQL statement for execution

__construct(string $type, string $host, string $user, string $pass, string $name = '', int $port = 0)

Constructor.

string
convertSQLFromMysql(string $line, string $type = 'ddl')

Convert a SQL request in Mysql syntax to native syntax

bool
select_db(string $database)

Select a database

false|resource|mysqli|mysqliDoli|Connection|SQLite3
connect(string $host, string $login, string $passwd, string $name, int $port = 0)

Connect to server

string
getVersion()

Return version of database server

string
getDriverInfo()

Return version of database client driver

bool
close()

Close database connection

bool|mysqli_result|resource
query(string $query, int $usesavepoint = 0, string $type = 'auto', int $result_mode = 0)

Execute a SQL request and return the resultset

static string
getCallerInfoString()

Get caller info

object|false
fetch_object(mysqli_result|resource|Connection|SQLite3Result $resultset)

Returns the current line (as an object) for the resultset cursor

array<int|string, mixed>|null|false
fetch_array(mysqli_result|resource|SQLite3Result $resultset)

Return data as an array

array<string|int, mixed>|null|int<0, 0>
fetch_row(mysqli_result|resource|SQLite3Result $resultset)

Return data as an array

int
num_rows(mysqli_result|resource|SQLite3Result $resultset)

Return number of lines for result of a SELECT

int
affected_rows(mysqli_result|resource|SQLite3Result $resultset)

Return the number of lines in the result of a request INSERT, DELETE or UPDATE

void
free(resource|mysqli_result|SQLite3Result $resultset = null)

Libere le dernier resultset utilise sur cette connection

string
escape(string $stringtoencode)

Escape a string to insert data

string
escapeforlike(string $stringtoencode)

Escape a string to insert data into a like

string
errno()

Return generic error code of last operation.

string
error()

Return description of last error

int
last_insert_id(string $tab, string $fieldid = 'rowid')

Get last ID after an insert INSERT

string
encrypt(string $fieldorvalue, int $withQuotes = 1)

Encrypt sensitive data in database Warning: This function includes the escape and add the SQL simple quotes on strings.

string
decrypt(string $value)

Decrypt sensitive data in database

string
DDLGetConnectId()

Return connection ID

bool|SQLite3Result|mysqli_result|resource
DDLCreateDb(string $database, string $charset = '', string $collation = '', string $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

DDLListTables($database, string $table = '')

List tables into a database

DDLListTablesFull($database, string $table = '')

List tables into a database

array<array<string, mixed>>
DDLInfoTable(string $table)

List information of columns in a table.

int
DDLCreateTable(string $table, array<string, array{type: string, label?: string, enabled?: int<0, 2>|string, position?: int, notnull?: int, visible?: int<-2, 5>|string, alwayseditable?: int<0, 1>, 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>, autofocusoncreate?: int<0, 1>, comment?: string, copytoclipboard?: int<1, 2>, validate?: int<0, 1>}> $fields, string $primary_key, string $type, ?array<string, mixed> $unique_keys = null, string[] $fulltext_keys = null, string[] $keys = null)

Create a table into database

int
DDLDropTable(string $table)

Drop a table into database

bool|resource|mysqli_result|SQLite3Result
DDLDescTable(string $table, string $field = "")

Return a pointer of line with description of a table or field

int
DDLAddField(string $table, string $field_name, array{type: string, label?: string, enabled?: int<0, 2>|string, position?: int, notnull?: int, visible?: int, noteditable?: int, default?: string, extra?: string, null?: 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, string $field_position = "")

Create a new field into table

int
DDLUpdateField(string $table, string $field_name, array{type: string, label: string, enabled: int<0, 2>|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)

Update format of a field into a table

int
DDLDropField(string $table, string $field_name)

Drop a field from table

int
DDLCreateUser(string $dolibarr_main_db_host, string $dolibarr_main_db_user, string $dolibarr_main_db_pass, string $dolibarr_main_db_name)

Create a user and privileges to connect to database (even if database does not exists yet)

string
getDefaultCharacterSetDatabase()

Return charset used to store data in current database Note: if we are connected to databasename, it is same result than using SELECT default_character_set_name FROM information_schema.SCHEMATA WHERE schema_name = "databasename";)

?array<int, array{charset: string, description: string}>
getListOfCharacterSet()

Return list of available charset that can be used to store data in database

string
getDefaultCollationDatabase()

Return collation used in current database

?array<int, array{collation: string}>
getListOfCollation()

Return list of available collation that can be used for database

string
getPathOfDump()

Return full path of dump program

string
getPathOfRestore()

Return full path of restore program

array<string, string>
getServerParametersValues(string $filter = '')

Return value of server parameters

array<string, string>
getServerStatusValues(string $filter = '')

Return value of server status (current indicators on memory, cache...)

Details

string prefix()

Return the DB prefix found into prefix_db (if it was set manually by doing $dbhandler->prefix_db=...).

Otherwise return MAIN_DB_PREFIX (common use).

Return Value

string

The DB prefix

string ifsql(string $test, string $resok, string $resko)

Format a SQL IF

Parameters

string $test

Test string (example: 'cd.statut=0', 'field IS NULL')

string $resok

result if test is equal

string $resko

result if test is not equal

Return Value

string

SQL string

string stddevpop(string $nameoffield)

Return SQL string to aggregate using the Standard Deviation of population

Parameters

string $nameoffield

Name of field

Return Value

string

SQL string

string hintindex(string $nameofindex, int $mode = 1)

Return SQL string to force an index

Parameters

string $nameofindex

Name of index

int $mode

0=Use, 1=Force

Return Value

string

SQL string

string regexpsql(string $subject, string $pattern, int $sqlstring = 0)

Format a SQL REGEXP

Parameters

string $subject

Field name to test

string $pattern

SQL pattern to match

int $sqlstring

0=the string being tested is a hard coded string, 1=the string is a field

Return Value

string

SQL string

string idate(int $param, "gmt"|"tzserver" $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

Parameters

int $param

Date TMS to convert

"gmt"|"tzserver" $gm

'gmt'=Input information are GMT values, 'tzserver'=Local to server TZ

Return Value

string

Date in a string YYYYMMDDHHMMSS

string lasterrno()

Return last error code

Return Value

string lasterrno

string sanitize(string $stringtosanitize, int $allowsimplequote = 0, int $allowsequals = 0, int $allowsspace = 0, int $allowschars = 1)

Sanitize a string for SQL forging

Parameters

string $stringtosanitize

String to escape

int $allowsimplequote

1=Allow simple quotes in string around val separated by "," but only when string is used as a list of SQL string "'aa', 'bb', 'cc', ..."). Can be used for IN ... 2=Allow all simple quotes. If you use this value, the return MUST be escaped to forge SQL strings.

int $allowsequals

1=Allow equals sign

int $allowsspace

1=Allow space char

int $allowschars

1=Allow a-z chars

Return Value

string

String escaped

int begin(string $textinlog = '')

Start transaction

Parameters

string $textinlog

Add a small text into log. '' by default.

Return Value

int

1 if transaction successfully opened or already opened, 0 if error

int commit(string $log = '')

Validate a database transaction

Parameters

string $log

Add more log to default log line

Return Value

int

1 if validation is OK or transaction level no started, 0 if ERROR

int rollback(string $log = '')

Cancel a transaction and go back to initial data values

@param  string          $log        Add more log to default log line

Parameters

string $log

Add more log to default log line

Return Value

int

1 if cancellation ok or transaction not open, 0 if error

string plimit(int $limit = 0, int $offset = 0)

Define limits and offset of request

Parameters

int $limit

Maximum number of lines returned (-1=conf->liste_limit, 0=no limit)

int $offset

Numero of line from where starting fetch

Return Value

string

String with SQL syntax to add a limit and offset

string[] getVersionArray()

Return version of database server into an array

Return Value

string[]

Version array

string lastquery()

Return last request executed with query()

Return Value

string

Last query

string order(string $sortfield = '', string $sortorder = '')

Define sort criteria of request

Parameters

string $sortfield

List of sort fields

string $sortorder

Sort order

Return Value

string

String to provide syntax of a sort sql string

string lasterror()

Return last error label

Return Value

string lasterror

int|"" jdate(string $string, bool $gm = 'tzserver')

Convert (by PHP) a PHP server TZ string date into a Timestamps date (GMT if gm=true) 19700101020000 -> 3600 with server TZ = +1 and $gm='tzserver' 19700101020000 -> 7200 whatever is server TZ if $gm='gmt'

@param  string              $string     Date in a string (YYYYMMDDHHMMSS, YYYYMMDD, YYYY-MM-DD HH:MM:SS)

Parameters

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

Return Value

int|""

Date TMS or ''

string lastqueryerror()

Return last query in error

Return Value

string lastqueryerror

bool|int|object getRow(string $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. It should only be used with SELECT queries Don't add LIMIT to your query, it will be added by this method

Parameters

string $sql

The sql query string

Return Value

bool|int|object

False on failure, 0 on empty, object on success

false|object[] getRows(string $sql)

Return all results from query as an array of objects. Using this is a bad practice and is discouraged.

Note : It should only be used with SELECT queries and with a limit. If you are not able to defined/know what can be the limit, it just means this function is not what you need. Do not use it.

Parameters

string $sql

The sql query string. Must end with "... LIMIT x"

Return Value

false|object[] Result

int getNextAutoIncrementId(string $table)

Get the last ID of an auto-increment field of a table

Parameters

string $table

Name of table

Return Value

int

Next ID or -1 if error

mixed prepare(string $sql)

Prepare a SQL statement for execution

Parameters

string $sql

SQL query to prepare

Return Value

mixed

Driver-specific prepared statement object or false on failure

__construct(string $type, string $host, string $user, string $pass, string $name = '', int $port = 0)

Constructor.

This create an opened connection to a database server and eventually to a database

Parameters

string $type

Type of database (mysql, pgsql...). Not used.

string $host

Address of database server

string $user

Name of database user

string $pass

Password of database user

string $name

Name of database

int $port

Port of database server

string convertSQLFromMysql(string $line, string $type = 'ddl')

Convert a SQL request in Mysql syntax to native syntax

@param string $line SQL request line to convert

Parameters

string $line

SQL request line to convert

string $type

Type of SQL order ('ddl' for insert, update, select, delete or 'dml' for create, alter...)

Return Value

string

SQL request line converted

bool select_db(string $database)

Select a database

@param string $database Name of database

Parameters

string $database

Name of database

Return Value

bool

true if OK, false if KO

false|resource|mysqli|mysqliDoli|Connection|SQLite3 connect(string $host, string $login, string $passwd, string $name, int $port = 0)

Connect to server

Parameters

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

Return Value

false|resource|mysqli|mysqliDoli|Connection|SQLite3

Database access handler

See also

close()

string getVersion()

Return version of database server

Return Value

string

Version string

string getDriverInfo()

Return version of database client driver

Return Value

string

Version string

bool close()

Close database connection

@return bool True if disconnect successful, false otherwise

Return Value

bool

True if disconnect successful, false otherwise

See also

connect()

bool|mysqli_result|resource query(string $query, int $usesavepoint = 0, string $type = 'auto', int $result_mode = 0)

Execute a SQL request and return the resultset

@param  string  $query          SQL query string

Parameters

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

Return Value

bool|mysqli_result|resource

Resultset of answer or false

final static protected string getCallerInfoString()

Get caller info

Return Value

string

object|false fetch_object(mysqli_result|resource|Connection|SQLite3Result $resultset)

Returns the current line (as an object) for the resultset cursor

Parameters

mysqli_result|resource|Connection|SQLite3Result $resultset

Handler of the desired request

Return Value

object|false

Object result line or false if KO or end of cursor

array<int|string, mixed>|null|false fetch_array(mysqli_result|resource|SQLite3Result $resultset)

Return data as an array

Parameters

mysqli_result|resource|SQLite3Result $resultset

Resultset of request

Return Value

array<int|string, mixed>|null|false

Result with row

array<string|int, mixed>|null|int<0, 0> fetch_row(mysqli_result|resource|SQLite3Result $resultset)

Return data as an array

Parameters

mysqli_result|resource|SQLite3Result $resultset

Resultset of request

Return Value

array<string|int, mixed>|null|int<0, 0> Array

int num_rows(mysqli_result|resource|SQLite3Result $resultset)

Return number of lines for result of a SELECT

Parameters

mysqli_result|resource|SQLite3Result $resultset

Resulset of requests

Return Value

int

Nb of lines

See also

affected_rows()

int affected_rows(mysqli_result|resource|SQLite3Result $resultset)

Return the number of lines in the result of a request INSERT, DELETE or UPDATE

Parameters

mysqli_result|resource|SQLite3Result $resultset

Cursor of the desired request

Return Value

int

Number of lines

See also

num_rows()

void free(resource|mysqli_result|SQLite3Result $resultset = null)

Libere le dernier resultset utilise sur cette connection

Parameters

resource|mysqli_result|SQLite3Result $resultset

Free cursor

Return Value

void

string escape(string $stringtoencode)

Escape a string to insert data

Parameters

string $stringtoencode

String to escape

Return Value

string

String escaped

string escapeforlike(string $stringtoencode)

Escape a string to insert data into a like

Parameters

string $stringtoencode

String to escape

Return Value

string

String escaped

string errno()

Return generic error code of last operation.

Return Value

string

Error code (Examples: DB_ERROR_TABLE_ALREADY_EXISTS, DB_ERROR_RECORD_ALREADY_EXISTS...)

string error()

Return description of last error

Return Value

string

Error text

int last_insert_id(string $tab, string $fieldid = 'rowid')

Get last ID after an insert INSERT

Parameters

string $tab

Table name concerned by insert. Not used under MySql but required for compatibility with Postgresql

string $fieldid

Field name

Return Value

int

Id of row

string encrypt(string $fieldorvalue, int $withQuotes = 1)

Encrypt sensitive data in database Warning: This function includes the escape and add the SQL simple quotes on strings.

Parameters

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).

Return Value

string

XXX(field) or XXX('value') or field or 'value'

string decrypt(string $value)

Decrypt sensitive data in database

Parameters

string $value

Value to decrypt

Return Value

string

Decrypted value if used

string DDLGetConnectId()

Return connection ID

Return Value

string

Id connection

bool|SQLite3Result|mysqli_result|resource DDLCreateDb(string $database, string $charset = '', string $collation = '', string $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

Parameters

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

Return Value

bool|SQLite3Result|mysqli_result|resource

Resource result of the query to create database if OK, null if KO

DDLListTables($database, string $table = '')

List tables into a database

@param string $database Name of database

Parameters

$database
string $table

Name of table filter ('xxx%') @return string[] of tables in an array

DDLListTablesFull($database, string $table = '')

List tables into a database

@param string $database Name of database

Parameters

$database
string $table

Name of table filter ('xxx%') @return array<array{0:string,1:string}> List of tables in an array

array<array<string, mixed>> DDLInfoTable(string $table)

List information of columns in a table.

Parameters

string $table

Name of table

Return Value

array<array<string, mixed>>

Array with information on table

int DDLCreateTable(string $table, array<string, array{type: string, label?: string, enabled?: int<0, 2>|string, position?: int, notnull?: int, visible?: int<-2, 5>|string, alwayseditable?: int<0, 1>, 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>, autofocusoncreate?: int<0, 1>, comment?: string, copytoclipboard?: int<1, 2>, validate?: int<0, 1>}> $fields, string $primary_key, string $type, ?array<string, mixed> $unique_keys = null, string[] $fulltext_keys = null, string[] $keys = null)

Create a table into database

Parameters

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, alwayseditable?: int<0, 1>, 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>, autofocusoncreate?: int<0, 1>, comment?: string, copytoclipboard?: int<1, 2>, validate?: int<0, 1>}> $fields

Associative table [field name][table of descriptions]

string $primary_key

Name of the field that will be the primary key

string $type

Type of the table

?array<string, mixed> $unique_keys

Associative array Name of fields that will be unique key => value

string[] $fulltext_keys

Field name table that will be indexed in fulltext

string[] $keys

Table of key fields names => value

Return Value

int

Return integer <0 if KO, >=0 if OK

int DDLDropTable(string $table)

Drop a table into database

Parameters

string $table

Name of table

Return Value

int

Return integer <0 if KO, >=0 if OK

bool|resource|mysqli_result|SQLite3Result DDLDescTable(string $table, string $field = "")

Return a pointer of line with description of a table or field

Parameters

string $table

Name of table

string $field

Optional : Name of field if we want description of field

Return Value

bool|resource|mysqli_result|SQLite3Result Resource

int DDLAddField(string $table, string $field_name, array{type: string, label?: string, enabled?: int<0, 2>|string, position?: int, notnull?: int, visible?: int, noteditable?: int, default?: string, extra?: string, null?: 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, string $field_position = "")

Create a new field into table

Parameters

string $table

Name of table

string $field_name

Name of field to add

array{type: string, label?: string, enabled?: int<0, 2>|string, position?: int, notnull?: int, visible?: int, noteditable?: int, default?: string, extra?: string, null?: 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

Associative array of description of the field to insert [parameter name][parameter value]

string $field_position

Optional ex .: "after field stuff"

Return Value

int

Return integer <0 if KO, >0 if OK

int DDLUpdateField(string $table, string $field_name, array{type: string, label: string, enabled: int<0, 2>|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)

Update format of a field into a table

Parameters

string $table

Name of table

string $field_name

Name of field to modify

array{type: string, label: string, enabled: int<0, 2>|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

Return Value

int

Return integer <0 if KO, >0 if OK

int DDLDropField(string $table, string $field_name)

Drop a field from table

Parameters

string $table

Name of table

string $field_name

Name of field to drop

Return Value

int

Return integer <0 if KO, >0 if OK

int DDLCreateUser(string $dolibarr_main_db_host, string $dolibarr_main_db_user, string $dolibarr_main_db_pass, string $dolibarr_main_db_name)

Create a user and privileges to connect to database (even if database does not exists yet)

Parameters

string $dolibarr_main_db_host

Server IP

string $dolibarr_main_db_user

Username to create

string $dolibarr_main_db_pass

User password to create

string $dolibarr_main_db_name

Database name where user must be granted

Return Value

int

Return integer <0 if KO, >=0 if OK

string getDefaultCharacterSetDatabase()

Return charset used to store data in current database Note: if we are connected to databasename, it is same result than using SELECT default_character_set_name FROM information_schema.SCHEMATA WHERE schema_name = "databasename";)

Return Value

string Charset

?array<int, array{charset: string, description: string}> getListOfCharacterSet()

Return list of available charset that can be used to store data in database

Return Value

?array<int, array{charset: string, description: string}>

List of Charset

string getDefaultCollationDatabase()

Return collation used in current database

Return Value

string

Collation value

?array<int, array{collation: string}> getListOfCollation()

Return list of available collation that can be used for database

Return Value

?array<int, array{collation: string}>

List of Collation

string getPathOfDump()

Return full path of dump program

Return Value

string

Full path of dump program

string getPathOfRestore()

Return full path of restore program

Return Value

string

Full path of restore program

array<string, string> getServerParametersValues(string $filter = '')

Return value of server parameters

Parameters

string $filter

Filter list on a particular value

Return Value

array<string, string>

Array of key-values (key=>value)

array<string, string> getServerStatusValues(string $filter = '')

Return value of server status (current indicators on memory, cache...)

Parameters

string $filter

Filter list on a particular value

Return Value

array<string, string>

Array of key-values (key=>value)