ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilDBPostgreSQL Class Reference

PostreSQL Database Wrapper. More...

+ Inheritance diagram for ilDBPostgreSQL:
+ Collaboration diagram for ilDBPostgreSQL:

Public Member Functions

 loadModule ($module)
 
 getDSN ()
 Get DSN. More...
 
 getDBType ()
 Get DB Type. More...
 
 initConnection ()
 Initialize the database connection. More...
 
 now ()
 now() More...
 
 constraintName ($a_table, $a_constraint)
 Constraint names must be "globally" unique in oracle. More...
 
 getPrimaryKeyIdentifier ()
 Primary key identifier. More...
 
 supportsFulltext ()
 Is fulltext index supported? More...
 
 replace ($a_table, $a_pk_columns, $a_other_columns)
 Replace into method. More...
 
 lockTables ($a_tables)
 Lock table. More...
 
 unlockTables ()
 Unlock tables. More...
 
 getStorageEngine ()
 
 dropFulltextIndex ($a_table, $a_name)
 
 setStorageEngine ($storage_engine)
 
 groupConcat ($a_field_name, $a_seperator=",", $a_order=null)
 
 locate ($a_needle, $a_string, $a_start_pos=1)
 
- Public Member Functions inherited from ilDB
 setDBUser ($a_user)
 Set database user. More...
 
 getDBUser ()
 Get database user. More...
 
 setDBPort ($a_port)
 Set database port. More...
 
 getDBPort ()
 Get database port. More...
 
 setDBHost ($a_host)
 Set database host. More...
 
 getDBHost ()
 Get database host. More...
 
 setDBPassword ($a_password)
 Set database password. More...
 
 getDBPassword ()
 Get database password. More...
 
 setDBName ($a_name)
 Set database name. More...
 
 getDBName ()
 Get database name. More...
 
 getDSN ()
 Get DSN. More...
 
 getDBVersion ()
 Get DB version. More...
 
 getDBType ()
 Get DSN. More...
 
 enableResultBuffering ($a_status)
 En/disable result buffering. More...
 
 initFromIniFile ($tmpClientIniFile=null)
 Init db parameters from ini file. More...
 
 connect ($a_return_false_for_error=false)
 Open the connection. More...
 
 doConnect ()
 Standard way to connect to db. More...
 
 disconnect ()
 Disconnect. More...
 
 getHostDSN ()
 Should return a valid value, if host connections are possible (connectHost) to create a new database from scratch. More...
 
 connectHost ()
 Sets up a host connection only (no specific database used). More...
 
 supportsFulltext ()
 
 supportsSlave ()
 Supports slave. More...
 
 supports ($feature)
 
 supportsTransactions ()
 
 useSlave ($a_val=true)
 Use slave. More...
 
 handleError ($a_res, $a_info="", $a_level="")
 Handle MDB2 Errors. More...
 
 raisePearError ($a_message, $a_level="")
 Raise an error. More...
 
 createDatabase ($a_name, $a_charset="utf8", $a_collation="")
 Create database. More...
 
 createTable ( $a_name, $a_definition_array, $a_drop_table=false, $a_ignore_erros=false)
 Create a new table in the database. More...
 
 dropTable ($a_name, $a_error_if_not_existing=true)
 Drop a table. More...
 
 alterTable ($a_name, $a_changes)
 Alter a table in the database This method is DEPRECATED, see http://www.ilias.de/docu/goto.php?target=pg_25354_42&client_id=docu PLEASE USE THE SPECIALIZED METHODS OF THIS CLASS TO CHANGE THE DB SCHEMA. More...
 
 addTableColumn ($a_table, $a_column, $a_attributes)
 Add table column Use this only on aleady "abstracted" tables. More...
 
 dropTableColumn ($a_table, $a_column)
 Drop table column Use this only on aleady "abstracted" tables. More...
 
 modifyTableColumn ($a_table, $a_column, $a_attributes)
 Modify a table column Use this only on aleady "abstracted" tables. More...
 
 renameTableColumn ($a_table, $a_column, $a_new_column)
 Rename a table column Use this only on aleady "abstracted" tables. More...
 
 renameTable ($a_name, $a_new_name)
 Rename a table. More...
 
 addPrimaryKey ($a_table, $a_fields)
 Add a primary key to a table. More...
 
 getPrimaryKeyIdentifier ()
 Primary key identifier. More...
 
 dropPrimaryKey ($a_table)
 Drop a primary key from a table. More...
 
 addFulltextIndex ($a_table, $a_fields, $a_name="in")
 Add fulltext index. More...
 
 isFulltextIndex ($a_table, $a_name)
 Is index a fulltext index? More...
 
 indexExistsByFields ($a_table, $a_fields)
 Check if index exists. More...
 
 dropIndexByFields ($a_table, $a_fields)
 Drop index by field(s) More...
 
 dropIndex ($a_table, $a_name="in")
 Drop an index from a table. More...
 
 addUniqueConstraint ($a_table, $a_fields, $a_name="con")
 Add a unique constraint to a table. More...
 
 dropUniqueConstraint ($a_table, $a_name="con")
 Drop a constraint from a table. More...
 
 dropUniqueConstraintByFields ($a_table, $a_fields)
 Drop constraint by field(s) More...
 
 createSequence ($a_table_name, $a_start=1)
 Create a sequence for a table. More...
 
 dropSequence ($a_table_name)
 Drop a sequence for a table. More...
 
 checkTableName ($a_name)
 Check whether a table name is valid. More...
 
 checkTableColumns ($a_cols)
 Check table columns definition. More...
 
 checkColumn ($a_col, $a_def)
 Check column definition. More...
 
 checkColumnDefinition ($a_def, $a_modify_mode=false)
 Check whether a column definition is valid. More...
 
 checkColumnName ($a_name)
 Check whether a column name is valid. More...
 
 checkIndexName ($a_name)
 Check whether an index name is valid. More...
 
 getAllowedAttributes ()
 
 constraintName ($a_table, $a_constraint)
 Determine contraint name by table name and constraint name. More...
 
 query ($sql, $a_handle_error=true)
 Query. More...
 
 queryF ($a_query, $a_types, $a_values)
 Formatted query (for SELECTS). More...
 
 manipulateF ($a_query, $a_types, $a_values)
 Formatted manupulate (for DELETE, UPDATE, INSERT). More...
 
 logStatement ($sql)
 Helper function, should usually not be called. More...
 
 setLimit ($a_limit, $a_offset=0)
 Set limit and offset for a query. More...
 
 nextId ($a_table_name)
 Get next ID for an index. More...
 
 manipulate ($sql)
 Data manipulation. More...
 
 prepare ($a_query, $a_types=null, $a_result_types=null)
 Prepare a query (SELECT) statement to be used with execute. More...
 
 prepareManip ($a_query, $a_types=null)
 Prepare a data manipulation statement to be used with execute. More...
 
 execute ($a_stmt, $a_data=null)
 Execute a query statement prepared by either prepare() or prepareManip() More...
 
 executeMultiple ($a_stmt, $a_data)
 Execute a query statement prepared by either prepare() or prepareManip() with multiple data arrays. More...
 
 insert ($a_table, $a_columns)
 Convenient method for standard insert statements, example field array: More...
 
 update ($a_table, $a_columns, $a_where)
 Convenient method for standard update statements, example field array: More...
 
 replace ($a_table, $a_pk_columns, $a_other_columns)
 Replace into method. More...
 
 fetchAssoc ($a_set)
 Fetch row as associative array from result set. More...
 
 free ($a_st)
 Free a statement / result set. More...
 
 fetchObject ($a_set)
 Fetch row as object from result set. More...
 
 numRows ($a_set)
 Fetch row as associative array from result set. More...
 
 in ($a_field, $a_values, $negate=false, $a_type="")
 Get abstract in-clause for given array. More...
 
 addTypesToArray ($a_arr, $a_type, $a_cnt)
 Adds a type x times to an array. More...
 
 now ()
 now() More...
 
 concat (array $a_values, $a_allow_null=true)
 Abstraction of SQL function CONCAT. More...
 
 substr ($a_exp, $a_pos=1, $a_len=-1)
 Substring. More...
 
 upper ($a_exp)
 Upper. More...
 
 lower ($a_exp)
 Upper. More...
 
 locate ($a_needle, $a_string, $a_start_pos=1)
 Create locate string. More...
 
 like ($a_col, $a_type, $a_value="?", $case_insensitive=true)
 Like. More...
 
 equals ($a_col, $a_value, $a_type, $a_empty_or_null=false)
 Use this only on text fields. More...
 
 equalsNot ($a_col, $a_value, $a_type, $a_empty_or_null=false)
 Use this only on text fields. More...
 
 fromUnixtime ($a_expr, $a_to_text=true)
 fromUnixtime (makes timestamp out of unix timestamp) More...
 
 unixTimestamp ()
 Unix timestamp. More...
 
 tableExists ($a_table)
 Check, whether a given table exists. More...
 
 tableColumnExists ($a_table, $a_column_name)
 Checks for the existence of a table column. More...
 
 uniqueConstraintExists ($a_table, array $a_fields)
 Checks if a unique constraint exists based on the fields of the unique constraint (not the name) More...
 
 listTables ()
 Get all tables. More...
 
 sequenceExists ($a_sequence)
 Check, whether a given sequence exists. More...
 
 listSequences ()
 Get all sequences. More...
 
 quote ($a_query, $a_type=null)
 Wrapper for quote method. More...
 
 quoteIdentifier ($a_identifier, $check_option=false)
 Quote table and field names. More...
 
 beginTransaction ()
 Begin Transaction. More...
 
 commit ()
 Commit a transaction. More...
 
 rollback ()
 Rollback a transaction. More...
 
 lockTables ($a_tables)
 Abstraction of lock table. More...
 
 unlockTables ()
 Unlock tables locked by previous lock table calls. More...
 
 autoExecute ($a_tablename, $a_fields, $a_mode=MDB2_AUTOQUERY_INSERT, $a_where=false)
 Wrapper for Pear autoExecute. More...
 
 getLastInsertId ()
 Get last insert id. More...
 
 getOne ($sql)
 getOne. More...
 
 getRow ($sql, $mode=ilDBConstants::FETCHMODE_OBJECT)
 getRow. More...
 
 setSubType ($a_value)
 Set sub type. More...
 
 getSubType ()
 Get sub type. More...
 
 migrateAllTablesToEngine ($engine=ilDBConstants::MYSQL_ENGINE_INNODB)
 
 supportsEngineMigration ()
 
 getSequenceName ($table_name)
 
 buildAtomQuery ()
 
 sanitizeMB4StringIfNotSupported ($query)
 
Parameters
$querystring to sanitize, all MB4-Characters like emojis will re replaced with ???
Returns
string sanitized query
More...
 
 doesCollationSupportMB4Strings ()
 @inheritDoc More...
 
 cast ($a_field_name, $a_dest_type)
 @inheritDoc More...
 
- Public Member Functions inherited from PEAR
 __construct ($error_class=null)
 Constructor. More...
 
 _PEAR ()
 Destructor (the emulated type of...). More...
 
 registerShutdownFunc ($func, $args=array())
 Use this function to register a shutdown method for static classes. More...
 
 isError ($data, $code=null)
 Tell whether a value is a PEAR error. More...
 
 expectError ($code=' *')
 This method is used to tell which errors you expect to get. More...
 
 popExpect ()
 This method pops one element off the expected error codes stack. More...
 
 _checkDelExpect ($error_code)
 This method checks unsets an error code if available. More...
 
 delExpect ($error_code)
 This method deletes all occurences of the specified element from the expected error codes stack. More...
 
raiseError ($message=null, $code=null, $mode=null, $options=null, $userinfo=null, $error_class=null, $skipmsg=false)
 This method is a wrapper that returns an instance of the configured error class with this object's default error handling applied. More...
 
throwError ($message=null, $code=null, $userinfo=null)
 Simpler form of raiseError with fewer options. More...
 
 staticPushErrorHandling ($mode, $options=null)
 
 staticPopErrorHandling ()
 
 pushErrorHandling ($mode, $options=null)
 Push a new error handler on top of the error handler options stack. More...
 
 popErrorHandling ()
 Pop the last error handler used. More...
 
 loadExtension ($ext)
 OS independant PHP extension load. More...
 
- Public Member Functions inherited from ilDBInterface
 doesCollationSupportMB4Strings ()
 
 sanitizeMB4StringIfNotSupported ($query)
 
 initFromIniFile ($tmpClientIniFile=null)
 
 connect ($return_false_on_error=false)
 
 nextId ($table_name)
 
 createTable ($table_name, $fields, $drop_table=false, $ignore_erros=false)
 
 addPrimaryKey ($table_name, $primary_keys)
 
 createSequence ($table_name, $start=1)
 
 getSequenceName ($table_name)
 
 tableExists ($table_name)
 
 tableColumnExists ($table_name, $column_name)
 
 addTableColumn ($table_name, $column_name, $attributes)
 
 dropTable ($table_name, $error_if_not_existing=true)
 
 renameTable ($old_name, $new_name)
 
 query ($query)
 Run a (read-only) Query on the database. More...
 
 fetchAll ($query_result, $fetch_mode=ilDBConstants::FETCHMODE_ASSOC)
 
 dropSequence ($table_name)
 
 dropTableColumn ($table_name, $column_name)
 
 renameTableColumn ($table_name, $column_old_name, $column_new_name)
 
 insert ($table_name, $values)
 
 fetchObject ($query_result)
 
 update ($table_name, $values, $where)
 
 manipulate ($query)
 Run a (write) Query on the database. More...
 
 fetchAssoc ($query_result)
 
 numRows ($query_result)
 
 quote ($value, $type)
 
 addIndex ($table_name, $fields, $index_name='', $fulltext=false)
 
 indexExistsByFields ($table_name, $fields)
 
 getDSN ()
 Get DSN. More...
 
 getDBType ()
 Get DSN. More...
 
 lockTables ($tables)
 Abstraction of lock table. More...
 
 unlockTables ()
 Unlock tables locked by previous lock table calls. More...
 
 in ($field, $values, $negate=false, $type="")
 
 queryF ($query, $types, $values)
 
 manipulateF ($query, $types, $values)
 
 useSlave ($bool)
 Return false iff slave is not supported. More...
 
 setLimit ($limit, $offset)
 
 like ($column, $type, $value="?", $case_insensitive=true)
 Generate a like subquery. More...
 
 now ()
 
 replace ($table, $primaryKeys, $otherColumns)
 Replace into method. More...
 
 equals ($columns, $value, $type, $emptyOrNull=false)
 
 setDBUser ($user)
 
 setDBPort ($port)
 
 setDBPassword ($password)
 
 setDBHost ($host)
 
 upper ($a_exp)
 
 lower ($a_exp)
 
 substr ($a_exp)
 
 prepare ($a_query, $a_types=null, $a_result_types=null)
 Prepare a query (SELECT) statement to be used with execute. More...
 
 prepareManip ($a_query, $a_types=null)
 
 enableResultBuffering ($a_status)
 
 execute ($stmt, $data=array())
 
 sequenceExists ($sequence)
 
 listSequences ()
 
 supports ($feature)
 
 supportsFulltext ()
 
 supportsSlave ()
 
 supportsTransactions ()
 
 listTables ()
 
 loadModule ($module)
 
 getAllowedAttributes ()
 
 concat (array $values, $allow_null=true)
 
 locate ($a_needle, $a_string, $a_start_pos=1)
 
 quoteIdentifier ($identifier, $check_option=false)
 
 modifyTableColumn ($table, $column, $attributes)
 
 free ($a_st)
 
 checkTableName ($a_name)
 
 beginTransaction ()
 
 commit ()
 
 rollback ()
 
 constraintName ($a_table, $a_constraint)
 
 dropIndex ($a_table, $a_name="i1")
 
 createDatabase ($a_name, $a_charset="utf8", $a_collation="")
 
 dropIndexByFields ($table_name, $afields)
 
 getPrimaryKeyIdentifier ()
 
 addFulltextIndex ($table_name, $afields, $a_name='in')
 
 dropFulltextIndex ($a_table, $a_name)
 
 isFulltextIndex ($a_table, $a_name)
 
 setStorageEngine ($storage_engine)
 
 getStorageEngine ()
 
 buildAtomQuery ()
 
 groupConcat ($a_field_name, $a_seperator=",", $a_order=null)
 
 cast ($a_field_name, $a_dest_type)
 

Static Public Member Functions

static getReservedWords ()
 Get reserved words. More...
 
- Static Public Member Functions inherited from ilDB
static getReservedWords ()
 Get reserved words. More...
 
static isDbError ($a_res)
 Check error. More...
 
static isReservedWord ($a_word)
 Checks whether a word is a reserved word in one of the supported databases. More...
 
- Static Public Member Functions inherited from PEAR
static & getStaticProperty ($class, $var)
 If you have a class that's mostly/entirely static, and you need static properties, you can use this method to simulate them. More...
 
static setErrorHandling ($mode=null, $options=null)
 Sets how errors generated by this object should be handled. More...
 
static getReservedWords ()
 Get reserved words. More...
 
static isReservedWord ($a_word)
 

Additional Inherited Members

- Data Fields inherited from ilDB
const LOCK_WRITE = 1
 
const LOCK_READ = 2
 
 $error_class
 
 $db
 
 $result
 
 $allowed_attributes
 
 $sub_type
 
- Data Fields inherited from PEAR
 $_debug = false
 
 $_default_error_mode = null
 
 $_default_error_options = null
 
 $_default_error_handler = ''
 
 $_error_class = 'PEAR_Error'
 
 $_expected_errors = array()
 
- Protected Member Functions inherited from ilDB
 initConnection ()
 Initialize the database connection. More...
 
 initHostConnection ()
 Initialize the host connection (no specific database) More...
 
 loadMDB2Extensions ()
 load additional mdb2 extensions and set their constants More...
 
 getCreateTableOptions ()
 Get options for the create table statement. More...
 

Detailed Description

PostreSQL Database Wrapper.

This class extends the main ILIAS database wrapper ilDB. Only a few methods should be overwritten, that contain PostreSQL specific statements and methods.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
Id
class.ilDB.php 18989 2009-02-15 12:57:19Z akill

Definition at line 18 of file class.ilDBPostgreSQL.php.

Member Function Documentation

◆ constraintName()

ilDBPostgreSQL::constraintName (   $a_table,
  $a_constraint 
)

Constraint names must be "globally" unique in oracle.

Reimplemented from ilDB.

Definition at line 94 of file class.ilDBPostgreSQL.php.

95 {
96 $a_constraint = str_replace($a_table . '_', '', $a_constraint);
97
98 return $a_table . "_" . $a_constraint;
99 }

◆ dropFulltextIndex()

ilDBPostgreSQL::dropFulltextIndex (   $a_table,
  $a_name 
)
Parameters
$a_table
$a_name
Returns
bool

Implements ilDBInterface.

Definition at line 252 of file class.ilDBPostgreSQL.php.

253 {
254 return false;
255 }

◆ getDBType()

ilDBPostgreSQL::getDBType ( )

Get DB Type.

Reimplemented from ilDB.

Definition at line 45 of file class.ilDBPostgreSQL.php.

46 {
47 return "postgres";
48 }

◆ getDSN()

ilDBPostgreSQL::getDSN ( )

Get DSN.

Reimplemented from ilDB.

Definition at line 36 of file class.ilDBPostgreSQL.php.

37 {
38 return "pgsql://" . $this->getDBUser() . ":" . $this->getDBPassword() . "@" .
39 $this->getDBHost() . "/" . $this->getDBName();
40 }
getDBUser()
Get database user.
Definition: class.ilDB.php:83
getDBName()
Get database name.
Definition: class.ilDB.php:163
getDBPassword()
Get database password.
Definition: class.ilDB.php:143
getDBHost()
Get database host.
Definition: class.ilDB.php:123

References ilDB\getDBHost(), ilDB\getDBName(), ilDB\getDBPassword(), and ilDB\getDBUser().

+ Here is the call graph for this function:

◆ getPrimaryKeyIdentifier()

ilDBPostgreSQL::getPrimaryKeyIdentifier ( )

Primary key identifier.

Reimplemented from ilDB.

Definition at line 104 of file class.ilDBPostgreSQL.php.

105 {
106 return "pk";
107 }

◆ getReservedWords()

static ilDBPostgreSQL::getReservedWords ( )
static

Get reserved words.

Reimplemented from ilDB.

Definition at line 53 of file class.ilDBPostgreSQL.php.

54 {
55 // version: 8.3.6
56 // url: http://www.postgresql.org/docs/current/static/sql-keywords-appendix.html
57 return array(
58 "ALL", "ANALYSE", "ANALYZE", "AND", "ANY", "ARRAY",
59 "AS", "ASC", "ASYMMETRIC", "AUTHORIZATION", "BETWEEN", "BINARY", "BOTH",
60 "CASE", "CAST", "CHECK", "COLLATE", "COLUMN", "CONSTRAINT", "CREATE",
61 "CROSS", "CURRENT_DATE", "CURRENT_ROLE", "CURRENT_TIME", "CURRENT_TIMESTAMP", "CURRENT_USER", "DEFAULT",
62 "DEFERRABLE", "DESC", "DISTINCT", "DO", "ELSE", "END", "EXCEPT",
63 "FALSE", "FOR", "FOREIGN", "FREEZE", "FROM", "FULL", "GRANT",
64 "GROUP", "HAVING", "ILIKE", "IN", "INITIALLY", "INNER", "INTERSECT",
65 "INTO", "IS", "ISNULL", "JOIN", "LEADING", "LEFT", "LIKE",
66 "LIMIT", "LOCALTIME", "LOCALTIMESTAMP", "NATURAL", "NEW", "NOT", "NOTNULL",
67 "NULL", "OFF", "OFFSET", "OLD", "ON", "ONLY", "OR",
68 "ORDER", "OUTER", "OVERLAPS", "PLACING", "PRIMARY", "REFERENCES", "RETURNING",
69 "RIGHT", "SELECT", "SESSION_USER", "SIMILAR", "SOME", "SYMMETRIC", "TABLE",
70 "THEN", "TO", "TRAILING", "TRUE", "UNION", "UNIQUE", "USER",
71 "USING", "VERBOSE", "WHEN", "WHERE", "WITH"
72 );
73 }

◆ getStorageEngine()

ilDBPostgreSQL::getStorageEngine ( )
Returns
string

Implements ilDBInterface.

Definition at line 246 of file class.ilDBPostgreSQL.php.

247 {
248 return null;
249 }

◆ groupConcat()

ilDBPostgreSQL::groupConcat (   $a_field_name,
  $a_seperator = ",",
  $a_order = null 
)
Parameters
string$a_field_name
string$a_seperator
string$a_order
Returns
string

Implements ilDBInterface.

Definition at line 271 of file class.ilDBPostgreSQL.php.

272 {
273 if ($a_order === null) {
274 $sql = "STRING_AGG(" . $a_field_name . ", " . $this->quote($a_seperator, "text") . ")";
275 } else {
276 $sql = "STRING_AGG(" . $a_field_name . ", " . $this->quote($a_seperator, "text") . " ORDER BY " . $a_order . ")";
277 }
278 return $sql;
279 }
quote($a_query, $a_type=null)
Wrapper for quote method.

References ilDB\quote().

+ Here is the call graph for this function:

◆ initConnection()

ilDBPostgreSQL::initConnection ( )

Initialize the database connection.

Reimplemented from ilDB.

Definition at line 78 of file class.ilDBPostgreSQL.php.

79 {
80 }

◆ loadModule()

ilDBPostgreSQL::loadModule (   $module)
Parameters
$module
Returns
mixed

Implements ilDBInterface.

Definition at line 25 of file class.ilDBPostgreSQL.php.

26 {
27 return $this->db->loadModule($module);
28 }
if($modEnd===false) $module
Definition: module.php:59

References $module.

◆ locate()

ilDBPostgreSQL::locate (   $a_needle,
  $a_string,
  $a_start_pos = 1 
)
Parameters
string$a_needle
string$a_string
int$a_start_pos
Returns
string

Reimplemented from ilDB.

Definition at line 289 of file class.ilDBPostgreSQL.php.

289 : string
290 {
291 $manager = $this->db->loadModule('Manager');
292 return $manager->getQueryUtils()->locate($a_needle, $a_string, $a_start_pos);
293 }

◆ lockTables()

ilDBPostgreSQL::lockTables (   $a_tables)

Lock table.

E.g $ilDB->lockTable('tree',ilDBConstants::LOCK_WRITE,'t1')

Parameters
array$a_tables
int$a_mode
string$a_alias
Deprecated:
Use ilAtomQuery instead
Returns

Reimplemented from ilDB.

Definition at line 199 of file class.ilDBPostgreSQL.php.

200 {
201 global $ilLog;
202
203 $locks = array();
204
205 $counter = 0;
206 foreach ($a_tables as $table) {
207 $lock = 'LOCK TABLE ';
208
209 $lock .= ($table['name'] . ' ');
210
211 switch ($table['type']) {
213 $lock .= ' IN SHARE MODE ';
214 break;
215
217 $lock .= ' IN EXCLUSIVE MODE ';
218 break;
219 }
220
221 $locks[] = $lock;
222 }
223
224 // @TODO use and store a unique identifier to allow nested lock/unlocks
225 $this->db->beginTransaction();
226 foreach ($locks as $lock) {
227 $this->db->query($lock);
228 if ($ilLog instanceof ilLog) {
229 $ilLog->write(__METHOD__ . ': ' . $lock);
230 }
231 }
232 return true;
233 }
logging
Definition: class.ilLog.php:19
$counter
if(empty($password)) $table
Definition: pwgen.php:24

References $counter, $ilLog, $table, ilDBConstants\LOCK_READ, and ilDBConstants\LOCK_WRITE.

◆ now()

ilDBPostgreSQL::now ( )

now()

Todo:
fix this

Reimplemented from ilDB.

Definition at line 86 of file class.ilDBPostgreSQL.php.

87 {
88 return "now()";
89 }

◆ replace()

ilDBPostgreSQL::replace (   $a_table,
  $a_pk_columns,
  $a_other_columns 
)

Replace into method.

Parameters
stringtable name
arrayprimary key values: array("field1" => array("text", $name), "field2" => ...)
arrayother values: array("field1" => array("text", $name), "field2" => ...)

Reimplemented from ilDB.

Definition at line 124 of file class.ilDBPostgreSQL.php.

125 {
126 $a_columns = array_merge($a_pk_columns, $a_other_columns);
127 $fields = array();
128 $field_values = array();
129 $placeholders = array();
130 $types = array();
131 $values = array();
132 $lobs = false;
133 $lob = array();
134 $val_field = array();
135 $a = array();
136 $b = array();
137 foreach ($a_columns as $k => $col) {
138 if ($col[0] == 'clob' or $col[0] == 'blob') {
139 $val_field[] = $this->quote($col[1], 'text') . " " . $k;
140 } else {
141 $val_field[] = $this->quote($col[1], $col[0]) . " " . $k;
142 }
143 $fields[] = $k;
144 $placeholders[] = "%s";
145 $placeholders2[] = ":$k";
146 $types[] = $col[0];
147 $values[] = $col[1];
148 $field_values[$k] = $col[1];
149 if ($col[0] == "blob" || $col[0] == "clob") {
150 $lobs = true;
151 $lob[$k] = $k;
152 }
153 $a[] = "a." . $k;
154 $b[] = "b." . $k;
155 }
156 $abpk = array();
157 $aboc = array();
158 $delwhere = array();
159 foreach ($a_pk_columns as $k => $col) {
160 $abpk[] = "a." . $k . " = b." . $k;
161 $delwhere[] = $k . " = " . $this->quote($col[1], $col[0]);
162 }
163 foreach ($a_other_columns as $k => $col) {
164 $aboc[] = "a." . $k . " = b." . $k;
165 }
166 // if ($lobs) // lobs -> use prepare execute (autoexecute broken in PEAR 2.4.1)
167 // {
168 $this->manipulate(
169 "DELETE FROM " . $a_table . " WHERE " .
170 implode($delwhere, " AND ")
171 );
172 $this->insert($a_table, $a_columns);
173
174 //$r = $this->db->extended->autoExecute($a_table, $field_values, MDB2_AUTOQUERY_INSERT, null, $types);
175 $this->handleError($r, "replace, delete/insert(" . $a_table . ")");
176 // }
177 /* else // if no lobs are used, use manipulate
178 {
179 $q = "MERGE INTO ".$a_table." a ".
180 "USING (SELECT ".implode($val_field, ", ")." ".
181 "FROM DUAL) b ON (".implode($abpk, " AND ").") ".
182 "WHEN MATCHED THEN UPDATE SET ".implode($aboc, ", ")." ".
183 "WHEN NOT MATCHED THEN INSERT (".implode($a, ",").") VALUES (".implode($b, ",").")";
184 $r = $this->manipulate($q);
185 }*/
186 return $r;
187 }
manipulate($sql)
Data manipulation.
handleError($a_res, $a_info="", $a_level="")
Handle MDB2 Errors.
Definition: class.ilDB.php:423
insert($a_table, $a_columns)
Convenient method for standard insert statements, example field array:
$r
Definition: example_031.php:79

References $r, ilDB\handleError(), ilDB\insert(), ilDB\manipulate(), and ilDB\quote().

+ Here is the call graph for this function:

◆ setStorageEngine()

ilDBPostgreSQL::setStorageEngine (   $storage_engine)
Parameters
$storage_engine

Implements ilDBInterface.

Definition at line 258 of file class.ilDBPostgreSQL.php.

259 {
260 return false;
261 }

◆ supportsFulltext()

ilDBPostgreSQL::supportsFulltext ( )

Is fulltext index supported?

Reimplemented from ilDB.

Definition at line 112 of file class.ilDBPostgreSQL.php.

113 {
114 return false;
115 }

◆ unlockTables()

ilDBPostgreSQL::unlockTables ( )

Unlock tables.

Deprecated:
Use ilAtomQuery instead
Returns

Reimplemented from ilDB.

Definition at line 240 of file class.ilDBPostgreSQL.php.

241 {
242 $this->db->commit();
243 }

The documentation for this class was generated from the following file: