dolibarr 25.0.0-alpha
Database.interface.php
1<?php
2/* Copyright (C) 2001 Fabien Seisen <seisen@linuxfr.org>
3 * Copyright (C) 2002-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
4 * Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
5 * Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
6 * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
7 * Copyright (C) 2014-2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
8 * Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
9 * Copyright (C) 2024-2026 Frédéric France <frederic.france@free.fr>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <https://www.gnu.org/licenses/>.
23 */
24
28interface Database
29{
38 public function ifsql($test, $resok, $resko);
39
46 public function stddevpop($nameoffield);
47
48 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
56 public function fetch_row($resultset);
57 // phpcs:enable
58
67 public function idate($param, $gm = 'tzserver');
68
74 public function lasterrno();
75
82 public function begin($textinlog = '');
83
84 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
96 public function DDLCreateDb($database, $charset = '', $collation = '', $owner = '');
97 // phpcs:enable
98
104 public function getVersionArray();
105
113 public function convertSQLFromMysql($line, $type = 'ddl');
114
115 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
123 public function affected_rows($resultset);
124 // phpcs:enable
125
131 public function error();
132
133 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
141 public function DDLListTables($database, $table = '');
142 // phpcs:enable
143
144 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
152 public function DDLListTablesFull($database, $table = '');
153 // phpcs:enable
154
160 public function lastquery();
161
169 public function order($sortfield = '', $sortorder = '');
170
177 public function decrypt($value);
178
179 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
186 public function fetch_array($resultset);
187 // phpcs:enable
188
194 public function lasterror();
195
202 public function escape($stringtoencode);
203
211 public function escapeforlike($stringtoencode);
212
219 public function sanitize($stringtosanitize);
220
221 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
229 public function last_insert_id($tab, $fieldid = 'rowid');
230 // phpcs:enable
231
237 public function getPathOfRestore();
238
245 public function rollback($log = '');
246
257 public function query($query, $usesavepoint = 0, $type = 'auto', $result_mode = 0);
258
271 public function connect($host, $login, $passwd, $name, $port = 0, $forcenew = false);
272
280 public function plimit($limit = 0, $offset = 0);
281
288 public function getServerParametersValues($filter = '');
289
296 public function getServerStatusValues($filter = '');
297
304
305 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
313 public function num_rows($resultset);
314 // phpcs:enable
315
321 public function getPathOfDump();
322
328 public function getDriverInfo();
329
335 public function errno();
336
337 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
350 public function DDLCreateTable($table, $fields, $primary_key, $type, $unique_keys = null, $fulltext_keys = null, $keys = null);
351 // phpcs:enable
352
353 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
360 public function DDLDropTable($table);
361 // phpcs:enable
362
368 public function getListOfCharacterSet();
369
370 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
380 public function DDLAddField($table, $field_name, $field_desc, $field_position = "");
381 // phpcs:enable
382
383 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
391 public function DDLDropField($table, $field_name);
392 // phpcs:enable
393
394 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
403 public function DDLUpdateField($table, $field_name, $field_desc);
404 // phpcs:enable
405
411 public function getListOfCollation();
412
413 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
421 public function DDLDescTable($table, $field = "");
422 // phpcs:enable
423
429 public function getVersion();
430
437
438 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
448 public function DDLCreateUser(
449 $dolibarr_main_db_host,
450 $dolibarr_main_db_user,
451 $dolibarr_main_db_pass,
452 $dolibarr_main_db_name
453 );
454 // phpcs:enable
455
456 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
463 public function DDLInfoTable($table);
464 // phpcs:enable
465
475 public function jdate($string, $gm = false);
476
485 public function encrypt($fieldorvalue, $withQuotes = 1);
486
493 public function commit($log = '');
494
501 public function free($resultset = null);
502
509 public function close();
510
516 public function lastqueryerror();
517
518 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
524 public function DDLGetConnectId();
525 // phpcs:enable
526
527 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
534 public function fetch_object($resultset);
535 // phpcs:enable
536
537 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
544 public function select_db($database);
545 // phpcs:enable
546
553 public function prepare($sql);
554
563 public function execute($stmt, $params = array());
564}
Class to manage Dolibarr database access for an SQL database.
DDLInfoTable($table)
List information of columns into a table.
error()
Return description of last error.
order($sortfield='', $sortorder='')
Define sort criteria of request.
lasterror()
Return last error label.
select_db($database)
Select a database.
commit($log='')
Validate a database transaction.
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)
DDLListTables($database, $table='')
List tables into a database.
fetch_array($resultset)
Return data as an array.
decrypt($value)
Decrypt sensitive data in database.
close()
Close database connection.
errno()
Return generic error code of last operation.
lasterrno()
Return last error code.
DDLGetConnectId()
Return connection ID.
execute($stmt, $params=array())
Execute a statement previously created with prepare().
rollback($log='')
Canceling a transaction and returning to old values.
encrypt($fieldorvalue, $withQuotes=1)
Encrypt sensitive data in database Warning: This function includes the escape and add the SQL simple ...
DDLDropField($table, $field_name)
Drop a field from table.
lastquery()
Return last request executed with query()
query($query, $usesavepoint=0, $type='auto', $result_mode=0)
Execute a SQL request and return the resultset.
ifsql($test, $resok, $resko)
Format a SQL IF.
DDLDescTable($table, $field="")
Return a pointer of line with description of a table or field.
sanitize($stringtosanitize)
Sanitize a string for SQL forging.
DDLCreateTable($table, $fields, $primary_key, $type, $unique_keys=null, $fulltext_keys=null, $keys=null)
Create a table into database.
escapeforlike($stringtoencode)
Escape a string to insert data into a like.
getListOfCollation()
Return list of available collation that can be used for database.
begin($textinlog='')
Start transaction.
DDLAddField($table, $field_name, $field_desc, $field_position="")
Create a new field into table.
DDLDropTable($table)
Drop a table into database.
getDriverInfo()
Return version of database client driver.
getVersion()
Return version of database server.
getServerStatusValues($filter='')
Return value of server status.
affected_rows($resultset)
Return the number of lines in the result of a request INSERT, DELETE or UPDATE.
getVersionArray()
Return version of database server into an array.
getListOfCharacterSet()
Return list of available charset that can be used to store data in database.
lastqueryerror()
Return last query in error.
getPathOfRestore()
Return full path of restore program.
getPathOfDump()
Return full path of dump program.
DDLListTablesFull($database, $table='')
List tables into a database with table type.
getDefaultCollationDatabase()
Return collation used in database.
DDLCreateDb($database, $charset='', $collation='', $owner='')
Create a new database Do not use function xxx_create_db (xxx=mysql, ...) as they are deprecated We fo...
stddevpop($nameoffield)
Return SQL string to aggregate using the Standard Deviation of population.
DDLUpdateField($table, $field_name, $field_desc)
Update format of a field into a table.
escape($stringtoencode)
Escape a string to insert data.
convertSQLFromMysql($line, $type='ddl')
Convert a SQL request in Mysql syntax to native syntax.
last_insert_id($tab, $fieldid='rowid')
Get last ID after an insert INSERT.
fetch_row($resultset)
Return data as an array @TODO deprecate this.
fetch_object($resultset)
Returns the current line (as an object) for the resultset cursor.
num_rows($resultset)
Return number of lines for result of a SELECT.
getServerParametersValues($filter='')
Return value of server parameters.
jdate($string, $gm=false)
Convert (by PHP) a PHP server TZ string date into a Timestamps date (GMT if gm=true) 19700101020000 -...
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.
prepare($sql)
Prepare a SQL statement for execution.
plimit($limit=0, $offset=0)
Define limits and offset of request.
connect($host, $login, $passwd, $name, $port=0, $forcenew=false)
Connection to server.
getDefaultCharacterSetDatabase()
Return charset used to store data in database.