dolibarr 19.0.3
|
Class to manage Dolibarr database access for a SQLite database. More...
Public Member Functions | |
__construct ($type, $host, $user, $pass, $name='', $port=0) | |
Constructor. | |
convertSQLFromMysql ($line, $type='ddl') | |
Convert a SQL request in Mysql syntax to native syntax. | |
select_db ($database) | |
Select a database. | |
connect ($host, $login, $passwd, $name, $port=0) | |
Connexion to server. | |
getVersion () | |
Return version of database server. | |
getDriverInfo () | |
Return version of database client driver. | |
close () | |
Close database connexion. | |
query ($query, $usesavepoint=0, $type='auto', $result_mode=0) | |
Execute a SQL request and return the resultset. | |
fetch_object ($resultset) | |
Returns the current line (as an object) for the resultset cursor. | |
fetch_array ($resultset) | |
Return datas as an array. | |
fetch_row ($resultset) | |
Return datas as an array. | |
num_rows ($resultset) | |
Return number of lines for result of a SELECT. | |
affected_rows ($resultset) | |
Return number of lines for result of a SELECT. | |
free ($resultset=null) | |
Free last resultset used. | |
escape ($stringtoencode) | |
Escape a string to insert data. | |
escapeforlike ($stringtoencode) | |
Escape a string to insert data into a like. | |
errno () | |
Renvoie le code erreur generique de l'operation precedente. | |
error () | |
Renvoie le texte de l'erreur mysql de l'operation precedente. | |
last_insert_id ($tab, $fieldid='rowid') | |
Get last ID after an insert INSERT. | |
encrypt ($fieldorvalue, $withQuotes=1) | |
Encrypt sensitive data in database Warning: This function includes the escape and add the SQL simple quotes on strings. | |
decrypt ($value) | |
Decrypt sensitive data in database. | |
DDLGetConnectId () | |
Return connexion ID. | |
DDLCreateDb ($database, $charset='', $collation='', $owner='') | |
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. | |
DDLListTables ($database, $table='') | |
List tables into a database. | |
DDLListTablesFull ($database, $table='') | |
List tables into a database with table type. | |
DDLInfoTable ($table) | |
List information of columns into a table. | |
DDLCreateTable ($table, $fields, $primary_key, $type, $unique_keys=null, $fulltext_keys=null, $keys=null) | |
Create a table into database. | |
DDLDropTable ($table) | |
Drop a table into database. | |
DDLDescTable ($table, $field="") | |
Return a pointer of line with description of a table or field. | |
DDLAddField ($table, $field_name, $field_desc, $field_position="") | |
Create a new field into table. | |
DDLUpdateField ($table, $field_name, $field_desc) | |
Update format of a field into a table. | |
DDLDropField ($table, $field_name) | |
Drop a field from table. | |
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) | |
getDefaultCharacterSetDatabase () | |
Return charset used to store data in database. | |
getListOfCharacterSet () | |
Return list of available charset that can be used to store data in database. | |
getDefaultCollationDatabase () | |
Return collation used in database. | |
getListOfCollation () | |
Return list of available collation that can be used for database. | |
getPathOfDump () | |
Return full path of dump program. | |
getPathOfRestore () | |
Return full path of restore program. | |
getServerParametersValues ($filter='') | |
Return value of server parameters. | |
getServerStatusValues ($filter='') | |
Return value of server status. | |
Public Member Functions inherited from DoliDB | |
prefix () | |
Return the DB prefix found into prefix_db (if it was set manually by doing $dbhandler->prefix_db=...). | |
ifsql ($test, $resok, $resko) | |
Format a SQL IF. | |
hintindex ($nameofindex) | |
Return SQL string to force an index. | |
regexpsql ($subject, $pattern, $sqlstring=0) | |
Format a SQL REGEXP. | |
idate ($param, $gm='tzserver') | |
Convert (by PHP) a GM Timestamp date into a string date with PHP server TZ to insert into a date field. | |
lasterrno () | |
Return last error code. | |
sanitize ($stringtosanitize, $allowsimplequote=0, $allowsequals=0, $allowsspace=0) | |
Sanitize a string for SQL forging. | |
begin ($textinlog='') | |
Start transaction. | |
commit ($log='') | |
Validate a database transaction. | |
rollback ($log='') | |
Cancel a transaction and go back to initial data values. | |
plimit ($limit=0, $offset=0) | |
Define limits and offset of request. | |
getVersionArray () | |
Return version of database server into an array. | |
lastquery () | |
Return last request executed with query() | |
order ($sortfield='', $sortorder='') | |
Define sort criteria of request. | |
lasterror () | |
Return last error label. | |
jdate ($string, $gm='tzserver') | |
Convert (by PHP) a PHP server TZ string date into a Timestamps date (GMT if gm=true) 19700101020000 -> 3600 with server TZ = +1 and $gm='tzserver' 19700101020000 -> 7200 whaterver is server TZ if $gm='gmt'. | |
lastqueryerror () | |
Return last query in error. | |
getRow ($sql) | |
Return first result from query as object Note : This method executes a given SQL query and retrieves the first row of results as an object. | |
getRows ($sql) | |
Return all results from query as an array of objects Note : This method executes a given SQL query and retrieves all row of results as an array of objects. | |
Public Member Functions inherited from Database | |
idate ($param) | |
Convert (by PHP) a GM Timestamp date into a string date with PHP server TZ to insert into a date field. | |
sanitize ($stringtosanitize) | |
Sanitize a string for SQL forging. | |
Public Attributes | |
$type = 'sqlite3' | |
Database type. | |
const | LABEL = 'Sqlite3' |
Database label. | |
const | VERSIONMIN = '3.0.0' |
Version min database. | |
Private Member Functions | |
addCustomFunction ($name, $arg_count=-1) | |
Permet le chargement d'une fonction personnalisee dans le moteur de base de donnees. | |
Static Private Member Functions | |
static | calc_daynr ($year, $month, $day) |
calc_daynr | |
static | calc_weekday ($daynr, $sunday_first_day_of_week) |
calc_weekday | |
static | calc_days_in_year ($year) |
calc_days_in_year | |
static | calc_week ($year, $month, $day, $week_behaviour, &$calc_year) |
calc_week | |
Class to manage Dolibarr database access for a SQLite database.
Definition at line 33 of file sqlite3.class.php.
DoliDBSqlite3::__construct | ( | $type, | |
$host, | |||
$user, | |||
$pass, | |||
$name = '', | |||
$port = 0 ) |
Constructor.
This create an opened connexion to a database server and eventually to a database
string | $type | Type of database (mysql, pgsql...). Not used. |
string | $host | Address of database server |
string | $user | Nom de l'utilisateur autorise |
string | $pass | Mot de passe |
string | $name | Nom de la database |
int | $port | Port of database server |
Definition at line 63 of file sqlite3.class.php.
References addCustomFunction(), connect(), dol_syslog(), and error().
|
private |
Permet le chargement d'une fonction personnalisee dans le moteur de base de donnees.
Note: le nom de la fonction personnalisee est prefixee par 'db'. La fonction doit ĂȘtre statique et publique. Le nombre de parametres est determine automatiquement.
string | $name | Le nom de la fonction a definir dans Sqlite |
int | $arg_count | Arg count |
Definition at line 1377 of file sqlite3.class.php.
References error().
Referenced by __construct().
DoliDBSqlite3::affected_rows | ( | $resultset | ) |
Return number of lines for result of a SELECT.
SQLite3Result | $resultset | Resulset of requests |
Implements Database.
Definition at line 603 of file sqlite3.class.php.
References num_rows().
|
staticprivate |
calc_daynr
int | $year | Year |
int | $month | Month |
int | $day | Day |
Definition at line 1402 of file sqlite3.class.php.
Referenced by calc_week().
|
staticprivate |
calc_days_in_year
string | $year | Year |
Definition at line 1441 of file sqlite3.class.php.
Referenced by calc_week().
|
staticprivate |
calc_week
string | $year | Year |
string | $month | Month |
string | $day | Day |
string | $week_behaviour | Week behaviour |
string | $calc_year | ??? |
Definition at line 1458 of file sqlite3.class.php.
References calc_daynr(), calc_days_in_year(), and calc_weekday().
|
staticprivate |
calc_weekday
int | $daynr | ??? |
bool | $sunday_first_day_of_week | ??? |
Definition at line 1427 of file sqlite3.class.php.
Referenced by calc_week().
DoliDBSqlite3::close | ( | ) |
Close database connexion.
Implements Database.
Definition at line 376 of file sqlite3.class.php.
References dol_syslog().
DoliDBSqlite3::connect | ( | $host, | |
$login, | |||
$passwd, | |||
$name, | |||
$port = 0 ) |
Connexion to server.
string | $host | database server host |
string | $login | login |
string | $passwd | password |
string | $name | name of database (not used for mysql, used for pgsql) |
integer | $port | Port of database server |
Implements Database.
Definition at line 320 of file sqlite3.class.php.
References dol_syslog(), and error().
Referenced by __construct().
DoliDBSqlite3::convertSQLFromMysql | ( | $line, | |
$type = 'ddl' ) |
Convert a SQL request in Mysql syntax to native syntax.
string | $line | SQL request line to convert |
string | $type | Type of SQL order ('ddl' for insert, update, select, delete or 'dml' for create, alter...) |
Implements Database.
Definition at line 139 of file sqlite3.class.php.
References $type, and dol_syslog().
Referenced by query().
DoliDBSqlite3::DDLAddField | ( | $table, | |
$field_name, | |||
$field_desc, | |||
$field_position = "" ) |
Create a new field into table.
string | $table | Name of table |
string | $field_name | Name of field to add |
string | $field_desc | Tableau associatif de description du champ a inserer[nom du parametre][valeur du parametre] |
string | $field_position | Optionnel ex.: "after champtruc" |
Implements Database.
Definition at line 1084 of file sqlite3.class.php.
DoliDBSqlite3::DDLCreateDb | ( | $database, | |
$charset = '', | |||
$collation = '', | |||
$owner = '' ) |
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.
string | $database | Database name to create |
string | $charset | Charset used to store data |
string | $collation | Charset used to sort data |
string | $owner | Username of database owner |
Implements Database.
Definition at line 845 of file sqlite3.class.php.
DoliDBSqlite3::DDLCreateTable | ( | $table, | |
$fields, | |||
$primary_key, | |||
$type, | |||
$unique_keys = null, | |||
$fulltext_keys = null, | |||
$keys = null ) |
Create a table into database.
string | $table | Nom de la table |
array | $fields | Tableau associatif [nom champ][tableau des descriptions] |
string | $primary_key | Nom du champ qui sera la clef primaire |
string | $type | Type de la table |
array | $unique_keys | Tableau associatifs Nom de champs qui seront clef unique => valeur |
array | $fulltext_keys | Tableau des Nom de champs qui seront indexes en fulltext |
array | $keys | Tableau des champs cles noms => valeur |
Implements Database.
Definition at line 969 of file sqlite3.class.php.
DoliDBSqlite3::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)
string | $dolibarr_main_db_host | Ip serveur |
string | $dolibarr_main_db_user | Nom user a creer |
string | $dolibarr_main_db_pass | Mot de passe user a creer |
string | $dolibarr_main_db_name | Database name where user must be granted |
Implements Database.
Definition at line 1178 of file sqlite3.class.php.
DoliDBSqlite3::DDLDescTable | ( | $table, | |
$field = "" ) |
Return a pointer of line with description of a table or field.
string | $table | Name of table |
string | $field | Optionnel : Name of field if we want description of field |
Implements Database.
Definition at line 1064 of file sqlite3.class.php.
DoliDBSqlite3::DDLDropField | ( | $table, | |
$field_name ) |
Drop a field from table.
string | $table | Name of table |
string | $field_name | Name of field to drop |
Implements Database.
Definition at line 1154 of file sqlite3.class.php.
DoliDBSqlite3::DDLDropTable | ( | $table | ) |
Drop a table into database.
string | $table | Name of table |
Implements Database.
Definition at line 1042 of file sqlite3.class.php.
DoliDBSqlite3::DDLGetConnectId | ( | ) |
Return connexion ID.
Implements Database.
Definition at line 826 of file sqlite3.class.php.
DoliDBSqlite3::DDLInfoTable | ( | $table | ) |
List information of columns into a table.
string | $table | Name of table |
Implements Database.
Definition at line 937 of file sqlite3.class.php.
DoliDBSqlite3::DDLListTables | ( | $database, | |
$table = '' ) |
List tables into a database.
string | $database | Name of database |
string | $table | Name of table filter ('xxx') |
Implements Database.
Definition at line 873 of file sqlite3.class.php.
DoliDBSqlite3::DDLListTablesFull | ( | $database, | |
$table = '' ) |
List tables into a database with table type.
string | $database | Name of database |
string | $table | Name of table filter ('xxx') |
Implements Database.
Definition at line 905 of file sqlite3.class.php.
DoliDBSqlite3::DDLUpdateField | ( | $table, | |
$field_name, | |||
$field_desc ) |
Update format of a field into a table.
string | $table | Name of table |
string | $field_name | Name of field to modify |
string | $field_desc | Array with description of field format |
Implements Database.
Definition at line 1130 of file sqlite3.class.php.
DoliDBSqlite3::decrypt | ( | $value | ) |
Decrypt sensitive data in database.
string | $value | Value to decrypt |
Implements Database.
Definition at line 796 of file sqlite3.class.php.
DoliDBSqlite3::encrypt | ( | $fieldorvalue, | |
$withQuotes = 1 ) |
Encrypt sensitive data in database Warning: This function includes the escape and add the SQL simple quotes on strings.
string | $fieldorvalue | Field name or value to encrypt |
int | $withQuotes | Return string including the SQL simple quotes. This param must always be 1 (Value 0 is bugged and deprecated). |
Implements Database.
Definition at line 767 of file sqlite3.class.php.
References escape().
DoliDBSqlite3::errno | ( | ) |
Renvoie le code erreur generique de l'operation precedente.
Implements Database.
Definition at line 666 of file sqlite3.class.php.
References error().
Referenced by query().
DoliDBSqlite3::error | ( | ) |
Renvoie le texte de l'erreur mysql de l'operation precedente.
Implements Database.
Definition at line 735 of file sqlite3.class.php.
Referenced by __construct(), addCustomFunction(), connect(), errno(), and query().
DoliDBSqlite3::escape | ( | $stringtoencode | ) |
Escape a string to insert data.
string | $stringtoencode | String to escape |
Implements Database.
Definition at line 645 of file sqlite3.class.php.
DoliDBSqlite3::escapeforlike | ( | $stringtoencode | ) |
Escape a string to insert data into a like.
string | $stringtoencode | String to escape |
Implements Database.
Definition at line 656 of file sqlite3.class.php.
DoliDBSqlite3::fetch_array | ( | $resultset | ) |
Return datas as an array.
SQLite3Result | $resultset | Resultset of request |
Implements Database.
Definition at line 538 of file sqlite3.class.php.
Referenced by getPathOfDump(), and getPathOfRestore().
DoliDBSqlite3::fetch_object | ( | $resultset | ) |
Returns the current line (as an object) for the resultset cursor.
SQLite3Result | $resultset | Curseur de la requete voulue |
Implements Database.
Definition at line 515 of file sqlite3.class.php.
DoliDBSqlite3::fetch_row | ( | $resultset | ) |
Return datas as an array.
SQLite3Result | $resultset | Resultset of request |
Implements Database.
Definition at line 557 of file sqlite3.class.php.
Referenced by getServerParametersValues().
DoliDBSqlite3::free | ( | $resultset = null | ) |
Free last resultset used.
SQLite3Result | $resultset | Curseur de la requete voulue |
Implements Database.
Definition at line 627 of file sqlite3.class.php.
DoliDBSqlite3::getDefaultCharacterSetDatabase | ( | ) |
Return charset used to store data in database.
Implements Database.
Definition at line 1218 of file sqlite3.class.php.
DoliDBSqlite3::getDefaultCollationDatabase | ( | ) |
Return collation used in database.
Implements Database.
Definition at line 1242 of file sqlite3.class.php.
DoliDBSqlite3::getDriverInfo | ( | ) |
Return version of database client driver.
Implements Database.
Definition at line 364 of file sqlite3.class.php.
DoliDBSqlite3::getListOfCharacterSet | ( | ) |
Return list of available charset that can be used to store data in database.
Implements Database.
Definition at line 1228 of file sqlite3.class.php.
DoliDBSqlite3::getListOfCollation | ( | ) |
Return list of available collation that can be used for database.
Implements Database.
Definition at line 1252 of file sqlite3.class.php.
DoliDBSqlite3::getPathOfDump | ( | ) |
Return full path of dump program.
Implements Database.
Definition at line 1266 of file sqlite3.class.php.
References fetch_array().
DoliDBSqlite3::getPathOfRestore | ( | ) |
Return full path of restore program.
Implements Database.
Definition at line 1285 of file sqlite3.class.php.
References fetch_array(), and query().
DoliDBSqlite3::getServerParametersValues | ( | $filter = '' | ) |
Return value of server parameters.
string | $filter | Filter list on a particular value |
Implements Database.
Definition at line 1305 of file sqlite3.class.php.
References fetch_row(), and query().
DoliDBSqlite3::getServerStatusValues | ( | $filter = '' | ) |
Return value of server status.
string | $filter | Filter list on a particular value |
Implements Database.
Definition at line 1352 of file sqlite3.class.php.
DoliDBSqlite3::getVersion | ( | ) |
Return version of database server.
Implements Database.
Definition at line 353 of file sqlite3.class.php.
DoliDBSqlite3::last_insert_id | ( | $tab, | |
$fieldid = 'rowid' ) |
Get last ID after an insert INSERT.
string | $tab | Table name concerned by insert. Ne sert pas sous MySql mais requis pour compatibilite avec Postgresql |
string | $fieldid | Field name |
Implements Database.
Definition at line 753 of file sqlite3.class.php.
DoliDBSqlite3::num_rows | ( | $resultset | ) |
Return number of lines for result of a SELECT.
SQLite3Result | $resultset | Resulset of requests |
Implements Database.
Definition at line 580 of file sqlite3.class.php.
Referenced by affected_rows().
DoliDBSqlite3::query | ( | $query, | |
$usesavepoint = 0, | |||
$type = 'auto', | |||
$result_mode = 0 ) |
Execute a SQL request and return the resultset.
string | $query | SQL query string |
int | $usesavepoint | 0=Default mode, 1=Run a savepoint before and a rollbock 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. |
string | $type | Type of SQL order ('ddl' for insert, update, select, delete or 'dml' for create, alter...) |
int | $result_mode | Result mode (not used with sqlite) |
Implements Database.
Definition at line 400 of file sqlite3.class.php.
References $type, convertSQLFromMysql(), dol_syslog(), errno(), error(), escape(), DoliDB\lasterrno(), DoliDB\lasterror(), DoliDB\lastquery(), DoliDB\lastqueryerror(), and query().
Referenced by getPathOfRestore(), getServerParametersValues(), and query().
DoliDBSqlite3::select_db | ( | $database | ) |
Select a database.
string | $database | Name of database |
Implements Database.
Definition at line 299 of file sqlite3.class.php.
References dol_syslog().