|
dolibarr
x.y.z
|
Class to drive a Postgresql database for Dolibarr. More...


Public Member Functions | |
| __construct ($type, $host, $user, $pass, $name='', $port=0) | |
| Constructor. More... | |
| select_db ($database) | |
| Select a database Ici postgresql n'a aucune fonction equivalente de mysql_select_db On compare juste manuellement si la database choisie est bien celle activee par la connexion. More... | |
| connect ($host, $login, $passwd, $name, $port=0) | |
| Connexion to server. More... | |
| getVersion () | |
| Return version of database server. More... | |
| getDriverInfo () | |
| Return version of database client driver. More... | |
| close () | |
| Close database connexion. More... | |
| query ($query, $usesavepoint=0, $type='auto', $result_mode=0) | |
| Convert request to PostgreSQL syntax, execute it and return the resultset. More... | |
| fetch_object ($resultset) | |
| Returns the current line (as an object) for the resultset cursor. More... | |
| fetch_array ($resultset) | |
| Return datas as an array. More... | |
| fetch_row ($resultset) | |
| Return datas as an array. More... | |
| num_rows ($resultset) | |
| Return number of lines for result of a SELECT. More... | |
| affected_rows ($resultset) | |
| Return the number of lines in the result of a request INSERT, DELETE or UPDATE. More... | |
| free ($resultset=null) | |
| Libere le dernier resultset utilise sur cette connexion. More... | |
| plimit ($limit=0, $offset=0) | |
| Define limits and offset of request. More... | |
| escape ($stringtoencode) | |
| Escape a string to insert data. More... | |
| escapeforlike ($stringtoencode) | |
| Escape a string to insert data into a like. More... | |
| ifsql ($test, $resok, $resko) | |
| Format a SQL IF. More... | |
| regexpsql ($subject, $pattern, $sqlstring=false) | |
| Format a SQL REGEXP. More... | |
| errno () | |
| Renvoie le code erreur generique de l'operation precedente. More... | |
| error () | |
| Renvoie le texte de l'erreur pgsql de l'operation precedente. More... | |
| last_insert_id ($tab, $fieldid='rowid') | |
| Get last ID after an insert INSERT. More... | |
| encrypt ($fieldorvalue, $withQuotes=1) | |
| Encrypt sensitive data in database Warning: This function includes the escape and add the SQL simple quotes on strings. More... | |
| decrypt ($value) | |
| Decrypt sensitive data in database. More... | |
| DDLGetConnectId () | |
| Return connexion ID. More... | |
| 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. More... | |
| DDLListTables ($database, $table='') | |
| List tables into a database. More... | |
| DDLInfoTable ($table) | |
| List information of columns into a table. More... | |
| DDLCreateTable ($table, $fields, $primary_key, $type, $unique_keys=null, $fulltext_keys=null, $keys=null) | |
| Create a table into database. More... | |
| DDLDropTable ($table) | |
| Drop a table into database. More... | |
| DDLCreateUser ($dolibarr_main_db_host, $dolibarr_main_db_user, $dolibarr_main_db_pass, $dolibarr_main_db_name) | |
| Create a user to connect to database. More... | |
| DDLDescTable ($table, $field="") | |
| Return a pointer of line with description of a table or field. More... | |
| DDLAddField ($table, $field_name, $field_desc, $field_position="") | |
| Create a new field into table. More... | |
| DDLUpdateField ($table, $field_name, $field_desc) | |
| Update format of a field into a table. More... | |
| DDLDropField ($table, $field_name) | |
| Drop a field from table. More... | |
| getDefaultCharacterSetDatabase () | |
| Return charset used to store data in database. More... | |
| getListOfCharacterSet () | |
| Return list of available charset that can be used to store data in database. More... | |
| getDefaultCollationDatabase () | |
| Return collation used in database. More... | |
| getListOfCollation () | |
| Return list of available collation that can be used for database. More... | |
| getPathOfDump () | |
| Return full path of dump program. More... | |
| getPathOfRestore () | |
| Return full path of restore program. More... | |
| getServerParametersValues ($filter='') | |
| Return value of server parameters. More... | |
| getServerStatusValues ($filter='') | |
| Return value of server status. More... | |
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=...). More... | |
| hintindex ($nameofindex) | |
| Return SQL string to force an index. More... | |
| 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. More... | |
| lasterrno () | |
| Return last error code. More... | |
| sanitize ($stringtosanitize, $allowsimplequote=0, $allowsequals=0) | |
| Sanitize a string for SQL forging. More... | |
| begin ($textinlog='') | |
| Start transaction. More... | |
| commit ($log='') | |
| Validate a database transaction. More... | |
| rollback ($log='') | |
| Cancel a transaction and go back to initial data values. More... | |
| getVersionArray () | |
| Return version of database server into an array. More... | |
| lastquery () | |
| Return last request executed with query() More... | |
| order ($sortfield=null, $sortorder=null) | |
| Define sort criteria of request. More... | |
| lasterror () | |
| Return last error label. More... | |
| 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'. More... | |
| lastqueryerror () | |
| Return last query in error. More... | |
| 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. More... | |
| 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. More... | |
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. More... | |
| sanitize ($stringtosanitize) | |
| Sanitize a string for SQL forging. More... | |
Static Public Member Functions | |
| static | convertSQLFromMysql ($line, $type='auto', $unescapeslashquot=false) |
| Convert a SQL request in Mysql syntax to native syntax. More... | |
Static Public Member Functions inherited from Database | |
| static | convertSQLFromMysql ($line, $type='ddl') |
| Convert a SQL request in Mysql syntax to native syntax. More... | |
Public Attributes | |
| $type = 'pgsql' | |
| Database type. | |
| const | LABEL = 'PostgreSQL' |
| Database label. | |
| $forcecharset = 'UTF8' | |
| Charset. | |
| $forcecollate = '' | |
| Collate used to force collate when creating database. | |
| const | VERSIONMIN = '9.0.0' |
| Version min database. | |
Class to drive a Postgresql database for Dolibarr.
Definition at line 36 of file pgsql.class.php.
| DoliDBPgsql::__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...) |
| 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 71 of file pgsql.class.php.
| DoliDBPgsql::affected_rows | ( | $resultset | ) |
Return the number of lines in the result of a request INSERT, DELETE or UPDATE.
| resource | $resultset | Result set of request |
Implements Database.
Definition at line 657 of file pgsql.class.php.
| DoliDBPgsql::close | ( | ) |
Close database connexion.
Implements Database.
Definition at line 487 of file pgsql.class.php.
References db, and dol_syslog().
| DoliDBPgsql::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 402 of file pgsql.class.php.
|
static |
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...) |
| bool | $unescapeslashquot | Unescape slash quote with quote quote |
Definition at line 152 of file pgsql.class.php.
| DoliDBPgsql::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 1178 of file pgsql.class.php.
| DoliDBPgsql::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 932 of file pgsql.class.php.
References $forcecharset, and $forcecollate.
| DoliDBPgsql::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 1033 of file pgsql.class.php.
| DoliDBPgsql::DDLCreateUser | ( | $dolibarr_main_db_host, | |
| $dolibarr_main_db_user, | |||
| $dolibarr_main_db_pass, | |||
| $dolibarr_main_db_name | |||
| ) |
Create a user to connect to database.
| string | $dolibarr_main_db_host | Ip server |
| string | $dolibarr_main_db_user | Name of user to create |
| string | $dolibarr_main_db_pass | Password of user to create |
| string | $dolibarr_main_db_name | Database name where user must be granted |
Implements Database.
Definition at line 1131 of file pgsql.class.php.
| DoliDBPgsql::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 1154 of file pgsql.class.php.
| DoliDBPgsql::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 1267 of file pgsql.class.php.
| DoliDBPgsql::DDLDropTable | ( | $table | ) |
Drop a table into database.
| string | $table | Name of table |
Implements Database.
Definition at line 1107 of file pgsql.class.php.
| DoliDBPgsql::DDLGetConnectId | ( | ) |
Return connexion ID.
Implements Database.
Definition at line 912 of file pgsql.class.php.
| DoliDBPgsql::DDLInfoTable | ( | $table | ) |
List information of columns into a table.
| string | $table | Name of table |
Implements Database.
Definition at line 988 of file pgsql.class.php.
| DoliDBPgsql::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 960 of file pgsql.class.php.
| DoliDBPgsql::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 1224 of file pgsql.class.php.
| DoliDBPgsql::decrypt | ( | $value | ) |
Decrypt sensitive data in database.
| int | $value | Value to decrypt |
Implements Database.
Definition at line 891 of file pgsql.class.php.
| DoliDBPgsql::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 870 of file pgsql.class.php.
| DoliDBPgsql::errno | ( | ) |
Renvoie le code erreur generique de l'operation precedente.
Implements Database.
Definition at line 771 of file pgsql.class.php.
References db.
| DoliDBPgsql::error | ( | ) |
Renvoie le texte de l'erreur pgsql de l'operation precedente.
Implements Database.
Definition at line 835 of file pgsql.class.php.
References db.
| DoliDBPgsql::escape | ( | $stringtoencode | ) |
Escape a string to insert data.
| string | $stringtoencode | String to escape |
Implements Database.
Definition at line 719 of file pgsql.class.php.
| DoliDBPgsql::escapeforlike | ( | $stringtoencode | ) |
Escape a string to insert data into a like.
| string | $stringtoencode | String to escape |
Implements Database.
Definition at line 730 of file pgsql.class.php.
| DoliDBPgsql::fetch_array | ( | $resultset | ) |
Return datas as an array.
| resource | $resultset | Resultset of request |
Implements Database.
Definition at line 604 of file pgsql.class.php.
| DoliDBPgsql::fetch_object | ( | $resultset | ) |
Returns the current line (as an object) for the resultset cursor.
| resource | $resultset | Curseur de la requete voulue |
Implements Database.
Definition at line 587 of file pgsql.class.php.
| DoliDBPgsql::fetch_row | ( | $resultset | ) |
Return datas as an array.
| resource | $resultset | Resultset of request |
Implements Database.
Definition at line 621 of file pgsql.class.php.
| DoliDBPgsql::free | ( | $resultset = null | ) |
Libere le dernier resultset utilise sur cette connexion.
| resource | $resultset | Result set of request |
Implements Database.
Definition at line 676 of file pgsql.class.php.
| DoliDBPgsql::getDefaultCharacterSetDatabase | ( | ) |
Return charset used to store data in database.
Implements Database.
Definition at line 1285 of file pgsql.class.php.
| DoliDBPgsql::getDefaultCollationDatabase | ( | ) |
Return collation used in database.
Implements Database.
Definition at line 1324 of file pgsql.class.php.
| DoliDBPgsql::getDriverInfo | ( | ) |
Return version of database client driver.
Implements Database.
Definition at line 476 of file pgsql.class.php.
| DoliDBPgsql::getListOfCharacterSet | ( | ) |
Return list of available charset that can be used to store data in database.
Implements Database.
Definition at line 1301 of file pgsql.class.php.
| DoliDBPgsql::getListOfCollation | ( | ) |
Return list of available collation that can be used for database.
Implements Database.
Definition at line 1340 of file pgsql.class.php.
| DoliDBPgsql::getPathOfDump | ( | ) |
Return full path of dump program.
Implements Database.
Definition at line 1362 of file pgsql.class.php.
| DoliDBPgsql::getPathOfRestore | ( | ) |
Return full path of restore program.
Implements Database.
Definition at line 1386 of file pgsql.class.php.
| DoliDBPgsql::getServerParametersValues | ( | $filter = '' | ) |
Return value of server parameters.
| string | $filter | Filter list on a particular value |
Implements Database.
Definition at line 1414 of file pgsql.class.php.
| DoliDBPgsql::getServerStatusValues | ( | $filter = '' | ) |
Return value of server status.
| string | $filter | Filter list on a particular value |
Implements Database.
Definition at line 1438 of file pgsql.class.php.
| DoliDBPgsql::getVersion | ( | ) |
Return version of database server.
Implements Database.
Definition at line 461 of file pgsql.class.php.
| DoliDBPgsql::ifsql | ( | $test, | |
| $resok, | |||
| $resko | |||
| ) |
Format a SQL IF.
| string | $test | Test string (example: 'cd.statut=0', 'field IS NULL') |
| string | $resok | resultat si test egal |
| string | $resko | resultat si test non egal |
Reimplemented from DoliDB.
Definition at line 743 of file pgsql.class.php.
| DoliDBPgsql::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 848 of file pgsql.class.php.
| DoliDBPgsql::num_rows | ( | $resultset | ) |
Return number of lines for result of a SELECT.
| resource | $resultset | Resulset of requests |
Implements Database.
Definition at line 639 of file pgsql.class.php.
| DoliDBPgsql::plimit | ( | $limit = 0, |
|
$offset = 0 |
|||
| ) |
Define limits and offset of request.
| int | $limit | Maximum number of lines returned (-1=conf->liste_limit, 0=no limit) |
| int | $offset | Numero of line from where starting fetch |
Reimplemented from DoliDB.
Definition at line 696 of file pgsql.class.php.
| resource boolean Resultset of last DoliDBPgsql::query | ( | $query, | |
$usesavepoint = 0, |
|||
$type = 'auto', |
|||
$result_mode = 0 |
|||
| ) |
Convert request to PostgreSQL syntax, execute it and return the resultset.
| string | $query | SQL query string |
| 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). |
| 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 pgsql) |
Implements Database.
Definition at line 508 of file pgsql.class.php.
Referenced by getDefaultCharacterSetDatabase(), getDefaultCollationDatabase(), getListOfCharacterSet(), getListOfCollation(), getPathOfDump(), getPathOfRestore(), and getVersion().
| DoliDBPgsql::regexpsql | ( | $subject, | |
| $pattern, | |||
$sqlstring = false |
|||
| ) |
Format a SQL REGEXP.
| string | $subject | string tested |
| string | $pattern | SQL pattern to match |
| string | $sqlstring | whether or not the string being tested is an SQL expression |
Reimplemented from DoliDB.
Definition at line 756 of file pgsql.class.php.
| DoliDBPgsql::select_db | ( | $database | ) |
Select a database Ici postgresql n'a aucune fonction equivalente de mysql_select_db On compare juste manuellement si la database choisie est bien celle activee par la connexion.
| string | $database | Name of database |
Implements Database.
Definition at line 381 of file pgsql.class.php.