dolibarr  17.0.4
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 
70  public function begin($textinlog = '');
71 
72  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
84  public function DDLCreateDb($database, $charset = '', $collation = '', $owner = '');
85  // phpcs:enable
86 
92  public function getVersionArray();
93 
101  public static function convertSQLFromMysql($line, $type = 'ddl');
102 
103  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
111  public function affected_rows($resultset);
112  // phpcs:enable
113 
119  public function error();
120 
121  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
129  public function DDLListTables($database, $table = '');
130  // phpcs:enable
131 
137  public function lastquery();
138 
146  public function order($sortfield = null, $sortorder = null);
147 
154  public function decrypt($value);
155 
156  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
163  public function fetch_array($resultset);
164  // phpcs:enable
165 
171  public function lasterror();
172 
179  public function escape($stringtoencode);
180 
188  public function escapeunderscore($stringtoencode);
189 
196  public function escapeforlike($stringtoencode);
197 
204  public function sanitize($stringtosanitize);
205 
206  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
214  public function last_insert_id($tab, $fieldid = 'rowid');
215  // phpcs:enable
216 
222  public function getPathOfRestore();
223 
230  public function rollback($log = '');
231 
242  public function query($query, $usesavepoint = 0, $type = 'auto', $result_mode = 0);
243 
255  public function connect($host, $login, $passwd, $name, $port = 0);
256 
264  public function plimit($limit = 0, $offset = 0);
265 
272  public function getServerParametersValues($filter = '');
273 
280  public function getServerStatusValues($filter = '');
281 
287  public function getDefaultCollationDatabase();
288 
289  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
297  public function num_rows($resultset);
298  // phpcs:enable
299 
305  public function getPathOfDump();
306 
312  public function getDriverInfo();
313 
319  public function errno();
320 
321  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
334  public function DDLCreateTable($table, $fields, $primary_key, $type, $unique_keys = null, $fulltext_keys = null, $keys = null);
335  // phpcs:enable
336 
337  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
344  public function DDLDropTable($table);
345  // phpcs:enable
346 
352  public function getListOfCharacterSet();
353 
354  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
364  public function DDLAddField($table, $field_name, $field_desc, $field_position = "");
365  // phpcs:enable
366 
367  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
375  public function DDLDropField($table, $field_name);
376  // phpcs:enable
377 
378  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
387  public function DDLUpdateField($table, $field_name, $field_desc);
388  // phpcs:enable
389 
395  public function getListOfCollation();
396 
397  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
405  public function DDLDescTable($table, $field = "");
406  // phpcs:enable
407 
413  public function getVersion();
414 
421 
422  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
432  public function DDLCreateUser(
433  $dolibarr_main_db_host,
434  $dolibarr_main_db_user,
435  $dolibarr_main_db_pass,
436  $dolibarr_main_db_name
437  );
438  // phpcs:enable
439 
449  public function jdate($string, $gm = false);
450 
459  public function encrypt($fieldorvalue, $withQuotes = 1);
460 
467  public function commit($log = '');
468 
469  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
476  public function DDLInfoTable($table);
477  // phpcs:enable
478 
485  public function free($resultset = null);
486 
493  public function close();
494 
500  public function lastqueryerror();
501 
502  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
508  public function DDLGetConnectId();
509  // phpcs:enable
510 
511  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
518  public function fetch_object($resultset);
519  // phpcs:enable
520 
521  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
528  public function select_db($database);
529  // phpcs:enable
530 }
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.
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 datas as an array.
decrypt($value)
Decrypt sensitive data in database.
close()
Close database connexion.
errno()
Return generic error code of last operation.
lasterrno()
Return last error code.
DDLGetConnectId()
Return connexion ID.
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()
connect($host, $login, $passwd, $name, $port=0)
Connexion to server.
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.
order($sortfield=null, $sortorder=null)
Define sort criteria of request.
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.
static convertSQLFromMysql($line, $type='ddl')
Convert a SQL request in Mysql syntax to native syntax.
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.
idate($param)
Convert (by PHP) a GM Timestamp date into a string date with PHP server TZ to insert into a date fiel...
lastqueryerror()
Return last query in error.
escapeunderscore($stringtoencode)
Escape a string to insert data.
getPathOfRestore()
Return full path of restore program.
getPathOfDump()
Return full path of dump program.
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...
DDLUpdateField($table, $field_name, $field_desc)
Update format of a field into a table.
escape($stringtoencode)
Escape a string to insert data.
last_insert_id($tab, $fieldid='rowid')
Get last ID after an insert INSERT.
fetch_row($resultset)
Return datas as an array.
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 -...
free($resultset=null)
Free last resultset used.
plimit($limit=0, $offset=0)
Define limits and offset of request.
getDefaultCharacterSetDatabase()
Return charset used to store data in database.