dolibarr  16.0.1
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  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <https://www.gnu.org/licenses/>.
21  */
22 
26 interface Database
27 {
36  public function ifsql($test, $resok, $resko);
37 
38  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
45  public function fetch_row($resultset);
46  // phpcs:enable
47 
55  public function idate($param);
56 
62  public function lasterrno();
63 
69  public function begin();
70 
71  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
83  public function DDLCreateDb($database, $charset = '', $collation = '', $owner = '');
84  // phpcs:enable
85 
91  public function getVersionArray();
92 
100  public static function convertSQLFromMysql($line, $type = 'ddl');
101 
102  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
110  public function affected_rows($resultset);
111  // phpcs:enable
112 
118  public function error();
119 
120  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
128  public function DDLListTables($database, $table = '');
129  // phpcs:enable
130 
136  public function lastquery();
137 
145  public function order($sortfield = null, $sortorder = null);
146 
153  public function decrypt($value);
154 
155  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
162  public function fetch_array($resultset);
163  // phpcs:enable
164 
170  public function lasterror();
171 
178  public function escape($stringtoencode);
179 
187  public function escapeunderscore($stringtoencode);
188 
195  public function escapeforlike($stringtoencode);
196 
203  public function sanitize($stringtosanitize);
204 
205  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
213  public function last_insert_id($tab, $fieldid = 'rowid');
214  // phpcs:enable
215 
221  public function getPathOfRestore();
222 
229  public function rollback($log = '');
230 
241  public function query($query, $usesavepoint = 0, $type = 'auto', $result_mode = 0);
242 
254  public function connect($host, $login, $passwd, $name, $port = 0);
255 
263  public function plimit($limit = 0, $offset = 0);
264 
271  public function getServerParametersValues($filter = '');
272 
279  public function getServerStatusValues($filter = '');
280 
286  public function getDefaultCollationDatabase();
287 
288  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
296  public function num_rows($resultset);
297  // phpcs:enable
298 
304  public function getPathOfDump();
305 
311  public function getDriverInfo();
312 
318  public function errno();
319 
320  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
333  public function DDLCreateTable($table, $fields, $primary_key, $type, $unique_keys = null, $fulltext_keys = null, $keys = null);
334  // phpcs:enable
335 
336  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
343  public function DDLDropTable($table);
344  // phpcs:enable
345 
351  public function getListOfCharacterSet();
352 
353  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
363  public function DDLAddField($table, $field_name, $field_desc, $field_position = "");
364  // phpcs:enable
365 
366  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
374  public function DDLDropField($table, $field_name);
375  // phpcs:enable
376 
377  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
386  public function DDLUpdateField($table, $field_name, $field_desc);
387  // phpcs:enable
388 
394  public function getListOfCollation();
395 
396  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
404  public function DDLDescTable($table, $field = "");
405  // phpcs:enable
406 
412  public function getVersion();
413 
419  public function getDefaultCharacterSetDatabase();
420 
421  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
431  public function DDLCreateUser(
432  $dolibarr_main_db_host,
433  $dolibarr_main_db_user,
434  $dolibarr_main_db_pass,
435  $dolibarr_main_db_name
436  );
437  // phpcs:enable
438 
448  public function jdate($string, $gm = false);
449 
458  public function encrypt($fieldorvalue, $withQuotes = 1);
459 
466  public function commit($log = '');
467 
468  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
475  public function DDLInfoTable($table);
476  // phpcs:enable
477 
484  public function free($resultset = null);
485 
492  public function close();
493 
499  public function lastqueryerror();
500 
501  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
507  public function DDLGetConnectId();
508  // phpcs:enable
509 
510  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
517  public function fetch_object($resultset);
518  // phpcs:enable
519 
520  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
527  public function select_db($database);
528  // phpcs:enable
529 }
Class to manage Dolibarr database access for an SQL database.
DDLDropField($table, $field_name)
Drop a field from table.
errno()
Return generic error code of last operation.
lasterror()
Return last error label.
idate($param)
Convert (by PHP) a GM Timestamp date into a string date with PHP server TZ to insert into a date fiel...
plimit($limit=0, $offset=0)
Define limits and offset of request.
close()
Close database connexion.
error()
Return description of last error.
DDLCreateDb($database, $charset= '', $collation= '', $owner= '')
Create a new database Do not use function xxx_create_db (xxx=mysql, ...) as they are deprecated We fo...
getListOfCollation()
Return list of available collation that can be used for database.
escapeforlike($stringtoencode)
Escape a string to insert data into a like.
DDLInfoTable($table)
List information of columns into a table.
sanitize($stringtosanitize)
Sanitize a string for SQL forging.
ifsql($test, $resok, $resko)
Format a SQL IF.
getDefaultCollationDatabase()
Return collation used in database.
DDLDescTable($table, $field="")
Return a pointer of line with description of a table or field.
static convertSQLFromMysql($line, $type= 'ddl')
Convert a SQL request in Mysql syntax to native syntax.
order($sortfield=null, $sortorder=null)
Define sort criteria of request.
getListOfCharacterSet()
Return list of available charset that can be used to store data in database.
DDLGetConnectId()
Return connexion ID.
fetch_object($resultset)
Returns the current line (as an object) for the resultset cursor.
last_insert_id($tab, $fieldid= 'rowid')
Get last ID after an insert INSERT.
free($resultset=null)
Free last resultset used.
getDefaultCharacterSetDatabase()
Return charset used to store data in database.
begin()
Start transaction.
num_rows($resultset)
Return number of lines for result of a SELECT.
commit($log= '')
Validate a database transaction.
DDLDropTable($table)
Drop a table into database.
getPathOfRestore()
Return full path of restore program.
decrypt($value)
Decrypt sensitive data in database.
getServerParametersValues($filter= '')
Return value of server parameters.
connect($host, $login, $passwd, $name, $port=0)
Connexion to server.
getVersion()
Return version of database server.
select_db($database)
Select a database.
DDLListTables($database, $table= '')
List tables into a database.
jdate($string, $gm=false)
Convert (by PHP) a PHP server TZ string date into a Timestamps date (GMT if gm=true) 19700101020000 -...
escape($stringtoencode)
Escape a string to insert data.
escapeunderscore($stringtoencode)
Escape a string to insert data.
getVersionArray()
Return version of database server into an array.
fetch_array($resultset)
Return datas as an array.
getServerStatusValues($filter= '')
Return value of server status.
fetch_row($resultset)
Return datas as an array.
lastqueryerror()
Return last query in error.
DDLUpdateField($table, $field_name, $field_desc)
Update format of a field into a table.
DDLAddField($table, $field_name, $field_desc, $field_position="")
Create a new field into table.
getDriverInfo()
Return version of database client driver.
query($query, $usesavepoint=0, $type= 'auto', $result_mode=0)
Execute a SQL request and return the resultset.
lasterrno()
Return last error code.
lastquery()
Return last request executed with query()
encrypt($fieldorvalue, $withQuotes=1)
Encrypt sensitive data in database Warning: This function includes the escape and add the SQL simple ...
rollback($log= '')
Canceling a transaction and returning to old values.
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) ...
getPathOfDump()
Return full path of dump program.
DDLCreateTable($table, $fields, $primary_key, $type, $unique_keys=null, $fulltext_keys=null, $keys=null)
Create a table into database.
affected_rows($resultset)
Return the number of lines in the result of a request INSERT, DELETE or UPDATE.