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);
264 return $this->
db->last_insert_id($tab, $fieldid);
274 return $this->
db->getPathOfRestore();
285 return $this->
db->rollback($log);
297 public function query($query, $usesavepoint = 0, $type =
'auto')
301 $resql = $this->
db->query($query, $usesavepoint, $type);
315 $this->startTime = microtime(
true);
316 $this->startMemory = memory_get_usage(
true);
328 $endTime = microtime(
true);
329 $duration = $endTime - $this->startTime;
330 $endMemory = memory_get_usage(
true);
331 $memoryDelta = $endMemory - $this->startMemory;
333 $this->queries[] = array(
335 'duration' => $duration,
336 'memory_usage' => $memoryDelta,
337 'is_success' =>
$resql ?
true :
false,
338 'error_code' =>
$resql ? null : $this->
db->lasterrno(),
339 'error_message' =>
$resql ? null : $this->
db->lasterror()
354 public function connect($host, $login, $passwd, $name, $port = 0)
356 return $this->
db->connect($host, $login, $passwd, $name, $port);
366 public function plimit($limit = 0, $offset = 0)
368 return $this->
db->plimit($limit, $offset);
379 return $this->
db->getServerParametersValues($filter);
390 return $this->
db->getServerStatusValues($filter);
400 return $this->
db->getDefaultCollationDatabase();
414 return $this->
db->num_rows($resultset);
424 return $this->
db->getPathOfDump();
434 return $this->
db->getDriverInfo();
444 return $this->
db->errno();
459 public function DDLCreateTable($table, $fields, $primary_key, $type, $unique_keys = null, $fulltext_keys = null, $keys = null)
461 return $this->
db->DDLCreateTable($table, $fields, $primary_key, $type, $unique_keys, $fulltext_keys, $keys);
472 return $this->
db->DDLDropTable($table);
482 return $this->
db->getListOfCharacterSet();
494 public function DDLAddField($table, $field_name, $field_desc, $field_position =
"")
496 return $this->
db->DDLAddField($table, $field_name, $field_desc, $field_position);
508 return $this->
db->DDLDropField($table, $field_name);
521 return $this->
db->DDLUpdateField($table, $field_name, $field_desc);
531 return $this->
db->getListOfCollation();
543 return $this->
db->DDLDescTable($table, $field);
553 return $this->
db->getVersion();
563 return $this->
db->getDefaultCharacterSetDatabase();
575 public function DDLCreateUser($dolibarr_main_db_host, $dolibarr_main_db_user, $dolibarr_main_db_pass, $dolibarr_main_db_name)
577 return $this->
db->DDLCreateUser($dolibarr_main_db_host, $dolibarr_main_db_user, $dolibarr_main_db_pass, $dolibarr_main_db_name);
590 public function jdate($string, $gm =
false)
593 return $this->
db->jdate($string, $gm);
604 public function encrypt($fieldorvalue, $withQuotes = 0)
606 return $this->
db->encrypt($fieldorvalue, $withQuotes);
617 return $this->
db->commit($log);
628 return $this->
db->DDLInfoTable($table);
637 public function free($resultset = null)
639 return $this->
db->free($resultset);
650 return $this->
db->close();
660 return $this->
db->lastqueryerror();
670 return $this->
db->DDLGetConnectId();
683 return $this->
db->fetch_object($resultset);
696 return $this->
db->select_db($database);
lastquery()
Return last request executed with query()
fetch_row($resultset)
Return datas as an array.
DDLUpdateField($table, $field_name, $field_desc)
Update format of a field into a table.
endTracing($sql, $resql)
End query tracing.
DDLListTables($database, $table= '')
List tables into a database.
getVersion()
Return version of database server.
DDLInfoTable($table)
List information of columns into a table.
rollback($log= '')
Cancel a transaction and go back to initial data values.
error()
Return description of last error.
fetch_object($resultset)
Renvoie la ligne courante (comme un objet) pour le curseur resultset.
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) ...
__construct($db)
Constructor.
getDefaultCharacterSetDatabase()
Return charset used to store data in database.
fetch_array($resultset)
Return datas as an array.
Class to manage Dolibarr database access.
getDriverInfo()
Return version of database client driver.
const LABEL
Database label
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...
free($resultset=null)
Free last resultset used.
last_insert_id($tab, $fieldid= 'rowid')
Get last ID after an insert INSERT.
getServerParametersValues($filter= '')
Return value of server parameters.
DDLCreateDb($database, $charset= '', $collation= '', $owner= '')
Create a new database Do not use function xxx_create_db (xxx=mysql, ...) as they are deprecated We fo...
$conf db
API class for accounts.
static convertSQLFromMysql($line, $type= 'ddl')
Convert a SQL request in Mysql syntax to native syntax.
getDefaultCollationDatabase()
Return collation used in database.
DDLCreateTable($table, $fields, $primary_key, $type, $unique_keys=null, $fulltext_keys=null, $keys=null)
Create a table into database.
getPathOfRestore()
Return full path of restore program.
query($query, $usesavepoint=0, $type= 'auto')
Execute a SQL request and return the resultset.
num_rows($resultset)
Return number of lines for result of a SELECT.
getServerStatusValues($filter= '')
Return value of server status.
lastqueryerror()
Return last query in error.
escape($stringtoencode)
Escape a string to insert data.
getListOfCharacterSet()
Return list of available charset that can be used to store data in database.
getVersionArray()
Return version of database server into an array.
errno()
Return generic error code of last operation.
lasterrno()
Return last error code.
startTracing()
Start query tracing.
getPathOfDump()
Return full path of dump program.
const VERSIONMIN
Version min database
close()
Close database connexion.
lasterror()
Return last error label.
DDLGetConnectId()
Return connexion ID.
commit($log= '')
Validate a database transaction.
connect($host, $login, $passwd, $name, $port=0)
Connexion to server.
encrypt($fieldorvalue, $withQuotes=0)
Encrypt sensitive data in database Warning: This function includes the escape, so it must use direct ...
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
select_db($database)
Select a database.
plimit($limit=0, $offset=0)
Define limits and offset of request.
decrypt($value)
Decrypt sensitive data in database.
DDLDropTable($table)
Drop a table into database.
getListOfCollation()
Return list of available collation that can be used for database.
DDLDropField($table, $field_name)
Drop a field from table.
jdate($string, $gm=false)
Convert (by PHP) a PHP server TZ string date into a Timestamps date (GMT if gm=true) 19700101020000 -...
DDLAddField($table, $field_name, $field_desc, $field_position="")
Create a new field into table.
affected_rows($resultset)
Return the number o flines into the result of a request INSERT, DELETE or UPDATE. ...
begin()
Start transaction.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
order($sortfield=null, $sortorder=null)
Define sort criteria of request.
ifsql($test, $resok, $resko)
Format a SQL IF.
DDLDescTable($table, $field="")
Return a pointer of line with description of a table or field.