3 require_once DOL_DOCUMENT_ROOT.
'/core/db/DoliDB.class.php';
27 protected $startMemory;
49 $this->
type = $this->
db->type;
50 $this->queries = array();
61 public function ifsql($test, $resok, $resko)
63 return $this->
db->ifsql($test, $resok, $resko);
76 return $this->
db->fetch_row($resultset);
87 public function idate($param, $gm =
'tzserver')
89 return $this->
db->idate($param, $gm);
99 return $this->
db->lasterrno();
109 return $this->
db->begin();
123 public function DDLCreateDb($database, $charset =
'', $collation =
'', $owner =
'')
125 return $this->
db->DDLCreateDb($database, $charset, $collation, $owner);
135 return $this->
db->getVersionArray();
147 return self::$db->convertSQLFromMysql($line);
161 return $this->
db->affected_rows($resultset);
171 return $this->
db->error();
183 return $this->
db->DDLListTables($database, $table);
193 return $this->
db->lastquery();
203 public function order($sortfield =
null, $sortorder =
null)
205 return $this->
db->order($sortfield, $sortorder);
216 return $this->
db->decrypt($value);
229 return $this->
db->fetch_array($resultset);
239 return $this->
db->lasterror();
250 return $this->
db->escape($stringtoencode);
262 return $this->
db->escapeunderscore($stringtoencode);
273 return str_replace(array(
'_',
'\\',
'%'), array(
'\_',
'\\\\',
'\%'), (
string) $stringtoencode);
287 return $this->
db->last_insert_id($tab, $fieldid);
297 return $this->
db->getPathOfRestore();
308 return $this->
db->rollback($log);
321 public function query($query, $usesavepoint = 0, $type =
'auto', $result_mode = 0)
325 $resql = $this->
db->query($query, $usesavepoint, $type, $result_mode);
339 $this->startTime = microtime(
true);
340 $this->startMemory = memory_get_usage(
true);
352 $endTime = microtime(
true);
353 $duration = $endTime - $this->startTime;
354 $endMemory = memory_get_usage(
true);
355 $memoryDelta = $endMemory - $this->startMemory;
357 $this->queries[] = array(
359 'duration' => $duration,
360 'memory_usage' => $memoryDelta,
361 'is_success' =>
$resql ?
true :
false,
362 'error_code' =>
$resql ?
null : $this->
db->lasterrno(),
363 'error_message' =>
$resql ?
null : $this->db->lasterror()
378 public function connect($host, $login, $passwd, $name, $port = 0)
380 return $this->
db->connect($host, $login, $passwd, $name, $port);
390 public function plimit($limit = 0, $offset = 0)
392 return $this->
db->plimit($limit, $offset);
403 return $this->
db->getServerParametersValues($filter);
414 return $this->
db->getServerStatusValues($filter);
424 return $this->
db->getDefaultCollationDatabase();
438 return $this->
db->num_rows($resultset);
448 return $this->
db->getPathOfDump();
458 return $this->
db->getDriverInfo();
468 return $this->
db->errno();
483 public function DDLCreateTable($table, $fields, $primary_key, $type, $unique_keys =
null, $fulltext_keys =
null, $keys =
null)
485 return $this->
db->DDLCreateTable($table, $fields, $primary_key, $type, $unique_keys, $fulltext_keys, $keys);
496 return $this->
db->DDLDropTable($table);
506 return $this->
db->getListOfCharacterSet();
518 public function DDLAddField($table, $field_name, $field_desc, $field_position =
"")
520 return $this->
db->DDLAddField($table, $field_name, $field_desc, $field_position);
532 return $this->
db->DDLDropField($table, $field_name);
545 return $this->
db->DDLUpdateField($table, $field_name, $field_desc);
555 return $this->
db->getListOfCollation();
567 return $this->
db->DDLDescTable($table, $field);
577 return $this->
db->getVersion();
587 return $this->
db->getDefaultCharacterSetDatabase();
599 public function DDLCreateUser($dolibarr_main_db_host, $dolibarr_main_db_user, $dolibarr_main_db_pass, $dolibarr_main_db_name)
601 return $this->
db->DDLCreateUser($dolibarr_main_db_host, $dolibarr_main_db_user, $dolibarr_main_db_pass, $dolibarr_main_db_name);
614 public function jdate($string, $gm =
false)
617 return $this->
db->jdate($string, $gm);
628 public function encrypt($fieldorvalue, $withQuotes = 1)
630 return $this->
db->encrypt($fieldorvalue, $withQuotes);
641 return $this->
db->commit($log);
652 return $this->
db->DDLInfoTable($table);
661 public function free($resultset =
null)
663 return $this->
db->free($resultset);
674 return $this->
db->close();
684 return $this->
db->lastqueryerror();
694 return $this->
db->DDLGetConnectId();
707 return $this->
db->fetch_object($resultset);
720 return $this->
db->select_db($database);
connect($host, $login, $passwd, $name, $port=0)
Connexion to server.
select_db($database)
Select a database.
$conf db
API class for accounts.
const LABEL
@const Database label
begin()
Start transaction.
fetch_object($resultset)
Returns the current line (as an object) for the resultset cursor.
DDLCreateDb($database, $charset='', $collation='', $owner='')
Create a new database Do not use function xxx_create_db (xxx=mysql, ...) as they are deprecated We fo...
Class to manage Dolibarr database access.
errno()
Return generic error code of last operation.
getServerParametersValues($filter='')
Return value of server parameters.
getDefaultCollationDatabase()
Return collation used in database.
getPathOfDump()
Return full path of dump program.
getVersionArray()
Return version of database server into an array.
lasterrno()
Return last error code.
escapeforlike($stringtoencode)
Escape a string to insert data into a like.
DDLDropTable($table)
Drop a table into database.
plimit($limit=0, $offset=0)
Define limits and offset of request.
getListOfCharacterSet()
Return list of available charset that can be used to store data in database.
close()
Close database connexion.
getVersion()
Return version of database server.
free($resultset=null)
Free last resultset used.
error()
Return description of last error.
const VERSIONMIN
@const Version min database
DDLUpdateField($table, $field_name, $field_desc)
Update format of a field into a table.
endTracing($sql, $resql)
End query tracing.
commit($log='')
Validate a database transaction.
jdate($string, $gm=false)
Convert (by PHP) a PHP server TZ string date into a Timestamps date (GMT if gm=true) 19700101020000 -...
fetch_array($resultset)
Return datas as an array.
encrypt($fieldorvalue, $withQuotes=1)
Encrypt sensitive data in database Warning: This function includes the escape and add the SQL simple ...
escapeunderscore($stringtoencode)
Escape a string to insert data.
decrypt($value)
Decrypt sensitive data in database.
escape($stringtoencode)
Escape a string to insert data.
num_rows($resultset)
Return number of lines for result of a SELECT.
last_insert_id($tab, $fieldid='rowid')
Get last ID after an insert INSERT.
DDLInfoTable($table)
List information of columns into a table.
getServerStatusValues($filter='')
Return value of server status.
getDefaultCharacterSetDatabase()
Return charset used to store data in database.
DDLCreateTable($table, $fields, $primary_key, $type, $unique_keys=null, $fulltext_keys=null, $keys=null)
Create a table into database.
query($query, $usesavepoint=0, $type='auto', $result_mode=0)
Execute a SQL request and return the resultset.
getPathOfRestore()
Return full path of restore program.
DDLDescTable($table, $field="")
Return a pointer of line with description of a table or field.
DDLGetConnectId()
Return connexion ID.
fetch_row($resultset)
Return datas as an array.
order($sortfield=null, $sortorder=null)
Define sort criteria of request.
DDLDropField($table, $field_name)
Drop a field from table.
static convertSQLFromMysql($line, $type='ddl')
Convert a SQL request in Mysql syntax to native syntax.
DDLListTables($database, $table='')
List tables into a database.
lasterror()
Return last error label.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice') && $user->rights->supplier_invoice->lire)) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
__construct($db)
Constructor.
ifsql($test, $resok, $resko)
Format a SQL IF.
affected_rows($resultset)
Return the number o flines into the result of a request INSERT, DELETE or UPDATE.
startTracing()
Start query tracing.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
getListOfCollation()
Return list of available collation that can be used for database.
lastquery()
Return last request executed with query()
lastqueryerror()
Return last query in error.
rollback($log='')
Cancel a transaction and go back to initial data values.
idate($param, $gm='tzserver')
Convert (by PHP) a GM Timestamp date into a string date with PHP server TZ to insert into a date fiel...
DDLAddField($table, $field_name, $field_desc, $field_position="")
Create a new field into table.
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)
getDriverInfo()
Return version of database client driver.