dolibarr  9.0.0
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 <http://www.gnu.org/licenses/>.
21  */
22 
26 interface Database
27 {
36  function ifsql($test, $resok, $resko);
37 
38  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
45  function fetch_row($resultset);
46  // phpcs:enable
47 
55  function idate($param);
56 
62  function lasterrno();
63 
69  function begin();
70 
71  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
83  function DDLCreateDb($database, $charset = '', $collation = '', $owner = '');
84  // phpcs:enable
85 
91  function getVersionArray();
92 
100  static function convertSQLFromMysql($line, $type = 'ddl');
101 
102  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
110  function affected_rows($resultset);
111  // phpcs:enable
112 
118  function error();
119 
120  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
128  function DDLListTables($database, $table = '');
129  // phpcs:enable
130 
136  function lastquery();
137 
145  function order($sortfield = null, $sortorder = null);
146 
153  function decrypt($value);
154 
155  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
162  function fetch_array($resultset);
163  // phpcs:enable
164 
170  function lasterror();
171 
178  function escape($stringtoencode);
179 
180  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
188  function last_insert_id($tab, $fieldid = 'rowid');
189  // phpcs:enable
190 
196  function getPathOfRestore();
197 
204  function rollback($log = '');
205 
215  function query($query, $usesavepoint = 0, $type = 'auto');
216 
228  function connect($host, $login, $passwd, $name, $port = 0);
229 
237  function plimit($limit = 0, $offset = 0);
238 
245  function getServerParametersValues($filter = '');
246 
253  function getServerStatusValues($filter = '');
254 
260  function getDefaultCollationDatabase();
261 
262  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
270  function num_rows($resultset);
271  // phpcs:enable
272 
278  function getPathOfDump();
279 
285  function getDriverInfo();
286 
292  function errno();
293 
294  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
307  function DDLCreateTable($table, $fields, $primary_key, $type, $unique_keys = null, $fulltext_keys = null, $keys = null);
308  // phpcs:enable
309 
310  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
317  function DDLDropTable($table);
318  // phpcs:enable
319 
325  function getListOfCharacterSet();
326 
327  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
337  function DDLAddField($table, $field_name, $field_desc, $field_position = "");
338  // phpcs:enable
339 
340  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
348  function DDLDropField($table, $field_name);
349  // phpcs:enable
350 
351  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
360  function DDLUpdateField($table, $field_name, $field_desc);
361  // phpcs:enable
362 
368  function getListOfCollation();
369 
370  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
378  function DDLDescTable($table, $field = "");
379  // phpcs:enable
380 
386  function getVersion();
387 
394 
395  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
405  function DDLCreateUser(
406  $dolibarr_main_db_host,
407  $dolibarr_main_db_user,
408  $dolibarr_main_db_pass,
409  $dolibarr_main_db_name
410  );
411  // phpcs:enable
412 
422  function jdate($string, $gm=false);
423 
432  function encrypt($fieldorvalue, $withQuotes = 0);
433 
440  function commit($log = '');
441 
442  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
449  function DDLInfoTable($table);
450  // phpcs:enable
451 
458  function free($resultset = null);
459 
466  function close();
467 
473  function lastqueryerror();
474 
475  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
481  function DDLGetConnectId();
482  // phpcs:enable
483 
484  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
491  function fetch_object($resultset);
492  // phpcs:enable
493 
494  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
501  function select_db($database);
502  // phpcs:enable
503 }
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.
commit($log='')
Validate a database transaction.
getServerParametersValues($filter='')
Return value of server parameters.
getListOfCollation()
Return list of available collation that can be used for database.
DDLInfoTable($table)
List information of columns into a table.
DDLCreateDb($database, $charset='', $collation='', $owner='')
Create a new database Do not use function xxx_create_db (xxx=mysql, ...) as they are deprecated We fo...
ifsql($test, $resok, $resko)
Format a SQL IF.
getDefaultCollationDatabase()
Return collation used in database.
static convertSQLFromMysql($line, $type='ddl')
Convert a SQL request in Mysql syntax to native syntax.
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.
getListOfCharacterSet()
Return list of available charset that can be used to store data in database.
DDLGetConnectId()
Return connexion ID.
fetch_object($resultset)
Renvoie la ligne courante (comme un objet) pour le curseur resultset.
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.
DDLListTables($database, $table='')
List tables into a database.
begin()
Start transaction.
num_rows($resultset)
Return number of lines for result of a SELECT.
DDLDropTable($table)
Drop a table into database.
getPathOfRestore()
Return full path of restore program.
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) ...
decrypt($value)
Decrypt sensitive data in database.
connect($host, $login, $passwd, $name, $port=0)
Connexion to server.
getVersion()
Return version of database server.
select_db($database)
Select a database.
encrypt($fieldorvalue, $withQuotes=0)
Encrypt sensitive data in database Warning: This function includes the escape, so it must use direct ...
query($query, $usesavepoint=0, $type='auto')
Execute a SQL request and return the resultset.
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.
getVersionArray()
Return version of database server into an array.
fetch_array($resultset)
Return datas as an array.
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.
getServerStatusValues($filter='')
Return value of server status.
lasterrno()
Return last error code.
lastquery()
Return last request executed with query()
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.
rollback($log='')
Annulation d&#39;une transaction et retour aux anciennes valeurs.
affected_rows($resultset)
Renvoie le nombre de lignes dans le resultat d&#39;une requete INSERT, DELETE ou UPDATE.