dolibarr  7.0.0-beta
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@capnetworks.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 
44  function fetch_row($resultset);
45 
53  function idate($param);
54 
60  function lasterrno();
61 
67  function begin();
68 
80  function DDLCreateDb($database, $charset = '', $collation = '', $owner = '');
81 
87  function getVersionArray();
88 
96  static function convertSQLFromMysql($line, $type = 'ddl');
97 
105  function affected_rows($resultset);
106 
112  function error();
113 
121  function DDLListTables($database, $table = '');
122 
128  function lastquery();
129 
137  function order($sortfield = null, $sortorder = null);
138 
145  function decrypt($value);
146 
153  function fetch_array($resultset);
154 
160  function lasterror();
161 
168  function escape($stringtoencode);
169 
177  function last_insert_id($tab, $fieldid = 'rowid');
178 
184  function getPathOfRestore();
185 
192  function rollback($log = '');
193 
203  function query($query, $usesavepoint = 0, $type = 'auto');
204 
216  function connect($host, $login, $passwd, $name, $port = 0);
217 
225  function plimit($limit = 0, $offset = 0);
226 
233  function getServerParametersValues($filter = '');
234 
241  function getServerStatusValues($filter = '');
242 
248  function getDefaultCollationDatabase();
249 
257  function num_rows($resultset);
258 
264  function getPathOfDump();
265 
271  function getDriverInfo();
272 
278  function errno();
279 
292  function DDLCreateTable($table, $fields, $primary_key, $type, $unique_keys = null, $fulltext_keys = null, $keys = null);
293 
300  function DDLDropTable($table);
301 
307  function getListOfCharacterSet();
308 
318  function DDLAddField($table, $field_name, $field_desc, $field_position = "");
319 
327  function DDLDropField($table, $field_name);
328 
337  function DDLUpdateField($table, $field_name, $field_desc);
338 
344  function getListOfCollation();
345 
353  function DDLDescTable($table, $field = "");
354 
360  function getVersion();
361 
368 
378  function DDLCreateUser(
379  $dolibarr_main_db_host,
380  $dolibarr_main_db_user,
381  $dolibarr_main_db_pass,
382  $dolibarr_main_db_name
383  );
384 
394  function jdate($string, $gm=false);
395 
404  function encrypt($fieldorvalue, $withQuotes = 0);
405 
412  function commit($log = '');
413 
420  function DDLInfoTable($table);
421 
428  function free($resultset = null);
429 
436  function close();
437 
443  function lastqueryerror();
444 
450  function DDLGetConnectId();
451 
458  function fetch_object($resultset);
459 
466  function select_db($database);
467 
468 }
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.
DDLInfoTable($table)
List information of columns into a table.
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)
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.
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.
query($query, $usesavepoint=0, $type= 'auto')
Execute a SQL request and return the resultset.
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.
encrypt($fieldorvalue, $withQuotes=0)
Encrypt sensitive data in database Warning: This function includes the escape, so it must use direct ...
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.
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.
lasterrno()
Return last error code.
lastquery()
Return last request executed with query()
rollback($log= '')
Annulation d'une transaction et retour aux anciennes valeurs.
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)
Renvoie le nombre de lignes dans le resultat d'une requete INSERT, DELETE ou UPDATE.