dolibarr/htdocs/core/db/Database.interface.php

533 lines
17 KiB
PHP
Raw Normal View History

2014-02-21 12:38:43 +01:00
<?php
/* Copyright (C) 2001 Fabien Seisen <seisen@linuxfr.org>
* Copyright (C) 2002-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
2018-10-27 14:43:12 +02:00
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
2015-05-12 19:01:01 +02:00
* Copyright (C) 2014-2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
2014-02-21 12:38:43 +01:00
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
2019-09-23 21:55:30 +02:00
* along with this program. If not, see <https://www.gnu.org/licenses/>.
2014-02-21 12:38:43 +01:00
*/
/**
* Class to manage Dolibarr database access for an SQL database
2014-02-21 12:38:43 +01:00
*/
interface Database
{
/**
2015-04-06 11:28:06 +02:00
* Format a SQL IF
2014-02-21 12:38:43 +01:00
*
2015-04-06 11:28:06 +02:00
* @param string $test Test string (example: 'cd.statut=0', 'field IS NULL')
2019-10-02 07:55:46 +02:00
* @param string $resok result if test is equal
* @param string $resko result if test is not equal
2015-04-06 11:28:06 +02:00
* @return string SQL string
2014-02-21 12:38:43 +01:00
*/
2019-10-02 07:55:46 +02:00
public function ifsql($test, $resok, $resko);
2014-02-21 12:38:43 +01:00
2019-10-02 07:55:46 +02:00
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
2014-02-21 12:38:43 +01:00
/**
2015-04-06 11:28:06 +02:00
* Return datas as an array
2014-02-21 12:38:43 +01:00
*
2015-04-06 11:28:06 +02:00
* @param resource $resultset Resultset of request
* @return array Array
2014-02-21 12:38:43 +01:00
*/
2019-10-02 07:55:46 +02:00
public function fetch_row($resultset);
// phpcs:enable
2014-02-21 12:38:43 +01:00
/**
2015-04-06 11:28:06 +02:00
* Convert (by PHP) a GM Timestamp date into a string date with PHP server TZ to insert into a date field.
* Function to use to build INSERT, UPDATE or WHERE predica
2014-02-21 12:38:43 +01:00
*
2015-04-06 11:28:06 +02:00
* @param int $param Date TMS to convert
* @return string Date in a string YYYYMMDDHHMMSS
2014-02-21 12:38:43 +01:00
*/
2019-10-02 07:55:46 +02:00
public function idate($param);
2014-02-21 12:38:43 +01:00
/**
2015-04-06 11:28:06 +02:00
* Return last error code
2014-02-21 12:38:43 +01:00
*
2015-04-06 11:28:06 +02:00
* @return string lasterrno
2014-02-21 12:38:43 +01:00
*/
2019-10-02 07:55:46 +02:00
public function lasterrno();
2014-02-21 12:38:43 +01:00
/**
* Start transaction
*
2022-10-06 17:09:10 +02:00
* @param string $textinlog Add a small text into log. '' by default.
* @return int 1 if transaction successfuly opened or already opened, 0 if error
2014-02-21 12:38:43 +01:00
*/
2022-10-06 17:09:10 +02:00
public function begin($textinlog = '');
2014-02-21 12:38:43 +01:00
2019-10-02 07:55:46 +02:00
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
2014-02-21 12:38:43 +01:00
/**
2015-04-06 11:28:06 +02:00
* Create a new database
* Do not use function xxx_create_db (xxx=mysql, ...) as they are deprecated
* We force to create database with charset this->forcecharset and collate this->forcecollate
2014-02-21 12:38:43 +01:00
*
2015-04-06 11:28:06 +02:00
* @param string $database Database name to create
* @param string $charset Charset used to store data
* @param string $collation Charset used to sort data
* @param string $owner Username of database owner
* @return resource resource defined if OK, null if KO
2014-02-21 12:38:43 +01:00
*/
2019-10-02 07:55:46 +02:00
public function DDLCreateDb($database, $charset = '', $collation = '', $owner = '');
// phpcs:enable
2014-02-21 12:38:43 +01:00
/**
2015-04-06 11:28:06 +02:00
* Return version of database server into an array
2014-02-21 12:38:43 +01:00
*
2015-04-06 11:28:06 +02:00
* @return array Version array
2014-02-21 12:38:43 +01:00
*/
2019-10-02 07:55:46 +02:00
public function getVersionArray();
2014-02-21 12:38:43 +01:00
/**
* Convert a SQL request in Mysql syntax to native syntax
*
2015-04-06 11:28:06 +02:00
* @param string $line SQL request line to convert
* @param string $type Type of SQL order ('ddl' for insert, update, select, delete or 'dml' for create, alter...)
* @return string SQL request line converted
2014-02-21 12:38:43 +01:00
*/
2019-03-01 19:24:06 +01:00
public static function convertSQLFromMysql($line, $type = 'ddl');
2014-02-21 12:38:43 +01:00
2019-10-02 07:55:46 +02:00
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
2014-02-21 12:38:43 +01:00
/**
2019-06-29 16:29:32 +02:00
* Return the number of lines in the result of a request INSERT, DELETE or UPDATE
2014-02-21 12:38:43 +01:00
*
2019-10-02 07:55:46 +02:00
* @param resource $resultset Cursor of the desired request
2019-06-29 16:29:32 +02:00
* @return int Number of lines
* @see num_rows()
2014-02-21 12:38:43 +01:00
*/
2019-10-02 07:55:46 +02:00
public function affected_rows($resultset);
// phpcs:enable
2014-02-21 12:38:43 +01:00
/**
2015-04-06 11:28:06 +02:00
* Return description of last error
2014-02-21 12:38:43 +01:00
*
2015-04-06 11:28:06 +02:00
* @return string Error text
2014-02-21 12:38:43 +01:00
*/
2019-10-02 07:55:46 +02:00
public function error();
2014-02-21 12:38:43 +01:00
2019-10-02 07:55:46 +02:00
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
2014-02-21 12:38:43 +01:00
/**
* List tables into a database
*
2014-11-15 15:19:37 +01:00
* @param string $database Name of database
2021-08-02 12:41:55 +02:00
* @param string $table Name of table filter ('xxx%')
2014-11-15 15:19:37 +01:00
* @return array List of tables in an array
2014-02-21 12:38:43 +01:00
*/
2019-10-02 07:55:46 +02:00
public function DDLListTables($database, $table = '');
// phpcs:enable
2014-02-21 12:38:43 +01:00
2023-04-14 10:06:10 +02:00
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* List tables into a database with table type
*
* @param string $database Name of database
* @param string $table Name of table filter ('xxx%')
* @return array List of tables in an array
*/
public function DDLListTablesFull($database, $table = '');
// phpcs:enable
2014-02-21 12:38:43 +01:00
/**
2015-04-06 11:28:06 +02:00
* Return last request executed with query()
2014-02-21 12:38:43 +01:00
*
2015-04-06 11:28:06 +02:00
* @return string Last query
2014-02-21 12:38:43 +01:00
*/
2019-10-02 07:55:46 +02:00
public function lastquery();
2014-02-21 12:38:43 +01:00
/**
* Define sort criteria of request
*
2015-04-06 11:28:06 +02:00
* @param string $sortfield List of sort fields
* @param string $sortorder Sort order
* @return string String to provide syntax of a sort sql string
2014-02-21 12:38:43 +01:00
*/
2019-10-02 07:55:46 +02:00
public function order($sortfield = null, $sortorder = null);
2014-02-21 12:38:43 +01:00
/**
2015-04-06 11:28:06 +02:00
* Decrypt sensitive data in database
2014-02-21 12:38:43 +01:00
*
* @param string $value Value to decrypt
2015-04-06 11:28:06 +02:00
* @return string Decrypted value if used
2014-02-21 12:38:43 +01:00
*/
2019-10-02 07:55:46 +02:00
public function decrypt($value);
2014-02-21 12:38:43 +01:00
2019-10-02 07:55:46 +02:00
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
2014-02-21 12:38:43 +01:00
/**
* Return datas as an array
*
2015-04-06 11:28:06 +02:00
* @param resource $resultset Resultset of request
* @return array Array
2014-02-21 12:38:43 +01:00
*/
2019-10-02 07:55:46 +02:00
public function fetch_array($resultset);
// phpcs:enable
2014-02-21 12:38:43 +01:00
/**
2015-04-06 11:28:06 +02:00
* Return last error label
2014-02-21 12:38:43 +01:00
*
2015-04-06 11:28:06 +02:00
* @return string lasterror
2014-02-21 12:38:43 +01:00
*/
2019-10-02 07:55:46 +02:00
public function lasterror();
2014-02-21 12:38:43 +01:00
/**
2015-04-06 11:28:06 +02:00
* Escape a string to insert data
2014-02-21 12:38:43 +01:00
*
* @param string $stringtoencode String to escape
* @return string String escaped
2014-02-21 12:38:43 +01:00
*/
2019-10-02 07:55:46 +02:00
public function escape($stringtoencode);
2014-02-21 12:38:43 +01:00
/**
* Escape a string to insert data into a like
*
* @param string $stringtoencode String to escape
* @return string String escaped
*/
public function escapeforlike($stringtoencode);
2020-09-18 17:13:01 +02:00
/**
* Sanitize a string for SQL forging
*
* @param string $stringtosanitize String to escape
* @return string String escaped
*/
public function sanitize($stringtosanitize);
2019-10-02 07:55:46 +02:00
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
2014-02-21 12:38:43 +01:00
/**
* Get last ID after an insert INSERT
*
2021-08-02 12:41:55 +02:00
* @param string $tab Table name concerned by insert. Not used under MySql but required for compatibility with Postgresql
2015-04-06 11:28:06 +02:00
* @param string $fieldid Field name
* @return int Id of row
2014-02-21 12:38:43 +01:00
*/
2019-10-02 07:55:46 +02:00
public function last_insert_id($tab, $fieldid = 'rowid');
// phpcs:enable
2014-02-21 12:38:43 +01:00
/**
* Return full path of restore program
*
* @return string Full path of restore program
*/
2019-10-02 07:55:46 +02:00
public function getPathOfRestore();
2014-02-21 12:38:43 +01:00
/**
2019-10-02 07:55:46 +02:00
* Canceling a transaction and returning to old values
2014-02-21 12:38:43 +01:00
*
2015-04-06 11:28:06 +02:00
* @param string $log Add more log to default log line
2019-10-02 07:55:46 +02:00
* @return int 1 if cancelation ok or transaction not open, 0 if error
2014-02-21 12:38:43 +01:00
*/
2019-10-02 07:55:46 +02:00
public function rollback($log = '');
2014-02-21 12:38:43 +01:00
/**
* Execute a SQL request and return the resultset
*
* @param string $query SQL query string
* @param int $usesavepoint 0=Default mode, 1=Run a savepoint before and a rollback to savepoint if error (this allow to have some request with errors inside global transactions).
* Note that with Mysql, this parameter is not used as Myssql can already commit a transaction even if one request is in error, without using savepoints.
* @param string $type Type of SQL order ('ddl' for insert, update, select, delete or 'dml' for create, alter...)
* @param int $result_mode Result mode
2021-12-21 15:23:56 +01:00
* @return bool|resource Resultset of answer or false
2014-02-21 12:38:43 +01:00
*/
public function query($query, $usesavepoint = 0, $type = 'auto', $result_mode = 0);
2014-02-21 12:38:43 +01:00
/**
* Connexion to server
*
2015-04-06 11:28:06 +02:00
* @param string $host database server host
* @param string $login login
* @param string $passwd password
* @param string $name name of database (not used for mysql, used for pgsql)
* @param int $port Port of database server
2015-04-06 11:28:06 +02:00
* @return resource Database access handler
2019-08-31 02:10:55 +02:00
* @see close()
2014-02-21 12:38:43 +01:00
*/
2019-10-02 07:55:46 +02:00
public function connect($host, $login, $passwd, $name, $port = 0);
2014-02-21 12:38:43 +01:00
/**
* Define limits and offset of request
*
2015-04-06 11:28:06 +02:00
* @param int $limit Maximum number of lines returned (-1=conf->liste_limit, 0=no limit)
* @param int $offset Numero of line from where starting fetch
* @return string String with SQL syntax to add a limit and offset
2014-02-21 12:38:43 +01:00
*/
2019-10-02 07:55:46 +02:00
public function plimit($limit = 0, $offset = 0);
2014-02-21 12:38:43 +01:00
/**
* Return value of server parameters
*
2015-04-06 11:28:06 +02:00
* @param string $filter Filter list on a particular value
* @return array Array of key-values (key=>value)
*/
2019-10-02 07:55:46 +02:00
public function getServerParametersValues($filter = '');
2014-02-21 12:38:43 +01:00
/**
2015-04-06 11:28:06 +02:00
* Return value of server status
2014-02-21 12:38:43 +01:00
*
2015-04-06 11:28:06 +02:00
* @param string $filter Filter list on a particular value
* @return array Array of key-values (key=>value)
2014-02-21 12:38:43 +01:00
*/
2019-10-02 07:55:46 +02:00
public function getServerStatusValues($filter = '');
2014-02-21 12:38:43 +01:00
/**
2015-04-06 11:28:06 +02:00
* Return collation used in database
2014-02-21 12:38:43 +01:00
*
2015-04-06 11:28:06 +02:00
* @return string Collation value
2014-02-21 12:38:43 +01:00
*/
2019-10-02 07:55:46 +02:00
public function getDefaultCollationDatabase();
2014-02-21 12:38:43 +01:00
2019-10-02 07:55:46 +02:00
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
2014-02-21 12:38:43 +01:00
/**
2015-04-06 11:28:06 +02:00
* Return number of lines for result of a SELECT
2014-02-21 12:38:43 +01:00
*
2015-04-06 11:28:06 +02:00
* @param resource $resultset Resulset of requests
* @return int Nb of lines
2019-08-31 02:10:55 +02:00
* @see affected_rows()
2014-02-21 12:38:43 +01:00
*/
2019-10-02 07:55:46 +02:00
public function num_rows($resultset);
// phpcs:enable
2014-02-21 12:38:43 +01:00
/**
2015-04-06 11:28:06 +02:00
* Return full path of dump program
2014-02-21 12:38:43 +01:00
*
* @return string Full path of dump program
*/
2019-10-02 07:55:46 +02:00
public function getPathOfDump();
2014-02-21 12:38:43 +01:00
/**
2015-04-06 11:28:06 +02:00
* Return version of database client driver
2014-02-21 12:38:43 +01:00
*
* @return string Version string
*/
2019-10-02 07:55:46 +02:00
public function getDriverInfo();
2014-02-21 12:38:43 +01:00
/**
2015-04-06 11:28:06 +02:00
* Return generic error code of last operation.
2014-02-21 12:38:43 +01:00
*
* @return string Error code (Exemples: DB_ERROR_TABLE_ALREADY_EXISTS, DB_ERROR_RECORD_ALREADY_EXISTS...)
*/
2019-10-02 07:55:46 +02:00
public function errno();
2014-02-21 12:38:43 +01:00
2019-10-02 07:55:46 +02:00
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
2014-02-21 12:38:43 +01:00
/**
2015-04-06 11:28:06 +02:00
* Create a table into database
2014-02-21 12:38:43 +01:00
*
2017-11-21 11:50:57 +01:00
* @param string $table Name of table
2019-10-02 07:55:46 +02:00
* @param array $fields Associative table [field name][table of descriptions]
* @param string $primary_key Name of the field that will be the primary key
* @param string $type Type of the table
* @param array $unique_keys Associative array Name of fields that will be unique key => value
* @param array $fulltext_keys Field name table that will be indexed in fulltext
* @param array $keys Table of key fields names => value
2015-04-06 11:28:06 +02:00
* @return int <0 if KO, >=0 if OK
2014-02-21 12:38:43 +01:00
*/
2019-10-02 07:55:46 +02:00
public function DDLCreateTable($table, $fields, $primary_key, $type, $unique_keys = null, $fulltext_keys = null, $keys = null);
// phpcs:enable
2014-02-21 12:38:43 +01:00
2019-10-02 07:55:46 +02:00
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
2017-11-21 11:50:57 +01:00
/**
* Drop a table into database
*
* @param string $table Name of table
* @return int <0 if KO, >=0 if OK
*/
2019-10-02 07:55:46 +02:00
public function DDLDropTable($table);
// phpcs:enable
2017-11-21 11:50:57 +01:00
2014-02-21 12:38:43 +01:00
/**
2015-04-06 11:28:06 +02:00
* Return list of available charset that can be used to store data in database
2014-02-21 12:38:43 +01:00
*
* @return array List of Charset
*/
2019-10-02 07:55:46 +02:00
public function getListOfCharacterSet();
2014-02-21 12:38:43 +01:00
2019-10-02 07:55:46 +02:00
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
2014-02-21 12:38:43 +01:00
/**
2015-04-06 11:28:06 +02:00
* Create a new field into table
2014-02-21 12:38:43 +01:00
*
2015-04-06 11:28:06 +02:00
* @param string $table Name of table
* @param string $field_name Name of field to add
2019-10-02 07:55:46 +02:00
* @param string $field_desc Associative array of description of the field to insert [parameter name][parameter value]
* @param string $field_position Optional ex .: "after field stuff"
2015-04-06 11:28:06 +02:00
* @return int <0 if KO, >0 if OK
2014-02-21 12:38:43 +01:00
*/
2019-10-02 07:55:46 +02:00
public function DDLAddField($table, $field_name, $field_desc, $field_position = "");
// phpcs:enable
2014-02-21 12:38:43 +01:00
2019-10-02 07:55:46 +02:00
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
2014-02-21 12:38:43 +01:00
/**
2015-04-06 11:28:06 +02:00
* Drop a field from table
2014-02-21 12:38:43 +01:00
*
2015-04-06 11:28:06 +02:00
* @param string $table Name of table
* @param string $field_name Name of field to drop
* @return int <0 if KO, >0 if OK
2014-02-21 12:38:43 +01:00
*/
2019-10-02 07:55:46 +02:00
public function DDLDropField($table, $field_name);
// phpcs:enable
2014-02-21 12:38:43 +01:00
2019-10-02 07:55:46 +02:00
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
2014-02-21 12:38:43 +01:00
/**
2015-04-06 11:28:06 +02:00
* Update format of a field into a table
2014-02-21 12:38:43 +01:00
*
2015-04-06 11:28:06 +02:00
* @param string $table Name of table
* @param string $field_name Name of field to modify
* @param string $field_desc Array with description of field format
* @return int <0 if KO, >0 if OK
2014-02-21 12:38:43 +01:00
*/
2019-10-02 07:55:46 +02:00
public function DDLUpdateField($table, $field_name, $field_desc);
// phpcs:enable
2014-02-21 12:38:43 +01:00
/**
2015-04-06 11:28:06 +02:00
* Return list of available collation that can be used for database
2014-02-21 12:38:43 +01:00
*
2015-04-06 11:28:06 +02:00
* @return array List of Collation
2014-02-21 12:38:43 +01:00
*/
2019-10-02 07:55:46 +02:00
public function getListOfCollation();
2014-02-21 12:38:43 +01:00
2019-10-02 07:55:46 +02:00
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
2014-02-21 12:38:43 +01:00
/**
2015-04-06 11:28:06 +02:00
* Return a pointer of line with description of a table or field
2014-02-21 12:38:43 +01:00
*
2015-04-06 11:28:06 +02:00
* @param string $table Name of table
2019-10-02 07:55:46 +02:00
* @param string $field Optional : Name of field if we want description of field
2015-04-06 11:28:06 +02:00
* @return resource Resource
2014-02-21 12:38:43 +01:00
*/
2019-10-02 07:55:46 +02:00
public function DDLDescTable($table, $field = "");
// phpcs:enable
2014-02-21 12:38:43 +01:00
/**
2015-04-06 11:28:06 +02:00
* Return version of database server
2014-02-21 12:38:43 +01:00
*
2015-04-06 11:28:06 +02:00
* @return string Version string
2014-02-21 12:38:43 +01:00
*/
2019-10-02 07:55:46 +02:00
public function getVersion();
2014-02-21 12:38:43 +01:00
/**
2015-04-06 11:28:06 +02:00
* Return charset used to store data in database
2014-02-21 12:38:43 +01:00
*
2015-04-06 11:28:06 +02:00
* @return string Charset
2014-02-21 12:38:43 +01:00
*/
2019-10-02 07:55:46 +02:00
public function getDefaultCharacterSetDatabase();
2014-02-21 12:38:43 +01:00
2019-10-02 07:55:46 +02:00
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
2014-02-21 12:38:43 +01:00
/**
2015-04-06 11:28:06 +02:00
* Create a user and privileges to connect to database (even if database does not exists yet)
2014-02-21 12:38:43 +01:00
*
2019-10-02 07:55:46 +02:00
* @param string $dolibarr_main_db_host Server IP
* @param string $dolibarr_main_db_user Username to create
* @param string $dolibarr_main_db_pass User password to create
2015-04-06 11:28:06 +02:00
* @param string $dolibarr_main_db_name Database name where user must be granted
2019-10-02 07:55:46 +02:00
* @return int <0 if KO, >=0 if OK
*/
public function DDLCreateUser(
$dolibarr_main_db_host,
$dolibarr_main_db_user,
$dolibarr_main_db_pass,
$dolibarr_main_db_name
);
// phpcs:enable
2014-02-21 12:38:43 +01:00
/**
2015-05-12 19:01:01 +02:00
* Convert (by PHP) a PHP server TZ string date into a Timestamps date (GMT if gm=true)
* 19700101020000 -> 3600 with TZ+1 and gmt=0
* 19700101020000 -> 7200 whaterver is TZ if gmt=1
*
2015-04-06 11:28:06 +02:00
* @param string $string Date in a string (YYYYMMDDHHMMSS, YYYYMMDD, YYYY-MM-DD HH:MM:SS)
2015-05-12 19:01:01 +02:00
* @param bool $gm 1=Input informations are GMT values, otherwise local to server TZ
2015-04-06 11:28:06 +02:00
* @return int|string Date TMS or ''
2015-05-12 19:01:01 +02:00
*/
2019-10-02 07:55:46 +02:00
public function jdate($string, $gm = false);
2014-02-21 12:38:43 +01:00
/**
2015-04-06 11:28:06 +02:00
* Encrypt sensitive data in database
2021-09-02 13:25:00 +02:00
* Warning: This function includes the escape and add the SQL simple quotes on strings.
2014-02-21 12:38:43 +01:00
*
2021-09-02 13:25:00 +02:00
* @param string $fieldorvalue Field name or value to encrypt
* @param int $withQuotes Return string including the SQL simple quotes. This param must always be 1 (Value 0 is bugged and deprecated).
* @return string XXX(field) or XXX('value') or field or 'value'
2014-02-21 12:38:43 +01:00
*/
2021-09-02 13:25:00 +02:00
public function encrypt($fieldorvalue, $withQuotes = 1);
2014-02-21 12:38:43 +01:00
/**
* Validate a database transaction
*
2015-04-06 11:28:06 +02:00
* @param string $log Add more log to default log line
* @return int 1 if validation is OK or transaction level no started, 0 if ERROR
2014-02-21 12:38:43 +01:00
*/
2019-10-02 07:55:46 +02:00
public function commit($log = '');
2014-02-21 12:38:43 +01:00
2019-10-02 07:55:46 +02:00
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
2014-02-21 12:38:43 +01:00
/**
2015-04-06 11:28:06 +02:00
* List information of columns into a table.
2014-02-21 12:38:43 +01:00
*
2015-04-06 11:28:06 +02:00
* @param string $table Name of table
2019-10-02 07:55:46 +02:00
* @return array Array with information on table
*/
public function DDLInfoTable($table);
// phpcs:enable
2014-02-21 12:38:43 +01:00
2019-10-02 07:55:46 +02:00
/**
2015-04-06 11:28:06 +02:00
* Free last resultset used.
2014-02-21 12:38:43 +01:00
*
2019-10-02 07:55:46 +02:00
* @param resource $resultset Free cursor
2015-04-06 11:28:06 +02:00
* @return void
2014-02-21 12:38:43 +01:00
*/
2019-10-02 07:55:46 +02:00
public function free($resultset = null);
2014-02-21 12:38:43 +01:00
/**
2015-04-06 11:28:06 +02:00
* Close database connexion
2014-02-21 12:38:43 +01:00
*
2015-04-06 11:28:06 +02:00
* @return boolean True if disconnect successfull, false otherwise
2019-08-31 02:10:55 +02:00
* @see connect()
2014-02-21 12:38:43 +01:00
*/
2019-10-02 07:55:46 +02:00
public function close();
2014-02-21 12:38:43 +01:00
/**
2015-04-06 11:28:06 +02:00
* Return last query in error
2014-02-21 12:38:43 +01:00
*
2015-04-06 11:28:06 +02:00
* @return string lastqueryerror
2014-02-21 12:38:43 +01:00
*/
2019-10-02 07:55:46 +02:00
public function lastqueryerror();
2014-02-21 12:38:43 +01:00
2019-10-02 07:55:46 +02:00
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
2014-02-21 12:38:43 +01:00
/**
* Return connexion ID
*
2015-04-06 11:28:06 +02:00
* @return string Id connexion
2014-02-21 12:38:43 +01:00
*/
2019-10-02 07:55:46 +02:00
public function DDLGetConnectId();
// phpcs:enable
2014-02-21 12:38:43 +01:00
2019-10-02 07:55:46 +02:00
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
2014-02-21 12:38:43 +01:00
/**
2019-10-02 07:55:46 +02:00
* Returns the current line (as an object) for the resultset cursor
2014-02-21 12:38:43 +01:00
*
2022-05-08 18:25:22 +02:00
* @param resource|Connection $resultset Handler of the desired request
* @return Object Object result line or false if KO or end of cursor
2014-02-21 12:38:43 +01:00
*/
2019-10-02 07:55:46 +02:00
public function fetch_object($resultset);
// phpcs:enable
2014-02-21 12:38:43 +01:00
2019-10-02 07:55:46 +02:00
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
2014-02-21 12:38:43 +01:00
/**
2015-04-06 11:28:06 +02:00
* Select a database
2014-02-21 12:38:43 +01:00
*
2015-04-06 11:28:06 +02:00
* @param string $database Name of database
* @return boolean true if OK, false if KO
2014-02-21 12:38:43 +01:00
*/
2019-10-02 07:55:46 +02:00
public function select_db($database);
// phpcs:enable
2014-02-21 12:38:43 +01:00
}