ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilDBPdoPostgreSQL Class Reference

Class ilDBPdoPostgreSQL. More...

+ Inheritance diagram for ilDBPdoPostgreSQL:
+ Collaboration diagram for ilDBPdoPostgreSQL:

Public Member Functions

 generateDSN ()
 
 connect ($return_false_for_error=false)
 
 initHelpers ()
 
 getPrimaryKeyIdentifier ()
 Primary key identifier. More...
 
 supportsFulltext ()
 
 supportsTransactions ()
 
 constraintName ($a_table, $a_constraint)
 
 getIndexName ($index_name_base)
 
 replace ($a_table, $a_pk_columns, $a_other_columns)
 
 lockTables ($a_tables)
 
 unlockTables ()
 
 getStorageEngine ()
 
 setStorageEngine ($storage_engine)
 
 nextId ($table_name)
 
 dropTable ($table_name, $error_if_not_existing=false)
 
 quoteIdentifier ($identifier, $check_option=false)
 
 tableExists ($table_name)
 
 tableColumnExists ($table_name, $column_name)
 
 renameTable ($a_name, $a_new_name)
 
 createSequence ($table_name, $start=1)
 
 createTable ($table_name, $fields, $drop_table=false, $ignore_erros=false)
 
 addPrimaryKey ($table_name, $primary_keys)
 
 addIndex ($table_name, $fields, $index_name='', $fulltext=false)
 
 addUniqueConstraint ($table, $fields, $name="con")
 
 dropPrimaryKey ($table_name)
 
- Public Member Functions inherited from ilDBPdo
 connect ($return_false_for_error=false)
 
 initHelpers ()
 
 getFieldDefinition ()
 
 setFieldDefinition ($field_definition)
 
 createDatabase ($a_name, $a_charset="utf8", $a_collation="")
 
 getLastErrorCode ()
 
 initFromIniFile ($tmpClientIniFile=null)
 
 generateDSN ()
 
 quoteIdentifier ($identifier, $check_option=false)
 
 nextId ($table_name)
 
 createTable ($table_name, $fields, $drop_table=false, $ignore_erros=false)
 
 checkColumnName ($a_name)
 
 addPrimaryKey ($table_name, $primary_keys)
 
 dropIndexByFields ($table_name, $fields)
 
 getPrimaryKeyIdentifier ()
 
 createSequence ($table_name, $start=1)
 
 tableExists ($table_name)
 
 tableColumnExists ($table_name, $column_name)
 
 addTableColumn ($table_name, $column_name, $attributes)
 
 dropTable ($table_name, $error_if_not_existing=true)
 
 query ($query)
 
 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, $columns, $where)
 
 manipulate ($query)
 
 fetchAssoc ($query_result)
 
 numRows ($query_result)
 
 quote ($value, $type=null)
 
 indexExistsByFields ($table_name, $fields)
 
 addIndex ($table_name, $fields, $index_name='', $fulltext=false)
 
 addFulltextIndex ($a_table, $a_fields, $a_name="in")
 
 dropFulltextIndex ($a_table, $a_name)
 Drop fulltext index. More...
 
 isFulltextIndex ($a_table, $a_name)
 Is index a fulltext index? More...
 
 getIndexName ($index_name_base)
 
 getSequenceName ($table_name)
 
 constraintName ($a_table, $a_constraint)
 Determine contraint name by table name and constraint name. More...
 
 getDSN ()
 
 getDBType ()
 
 setDBType ($type)
 
 lockTables ($tables)
 
 unlockTables ()
 
 in ($field, $values, $negate=false, $type="")
 
 queryF ($query, $types, $values)
 
 manipulateF ($query, $types, $values)
 
 useSlave ($bool)
 
 setLimit ($limit, $offset=0)
 Set the Limit for the next Query. More...
 
 like ($column, $type, $value="?", $case_insensitive=true)
 
 now ()
 
 replace ($table, $primaryKeys, $otherColumns)
 Replace into method. More...
 
 equals ($columns, $value, $type, $emptyOrNull=false)
 
 getHost ()
 
 setHost ($host)
 
 getDbname ()
 
 setDbname ($dbname)
 
 getCharset ()
 
 setCharset ($charset)
 
 getUsername ()
 
 setUsername ($username)
 
 getPassword ()
 
 setPassword ($password)
 
 getPort ()
 
 setPort ($port)
 
 setDBUser ($user)
 
 setDBPort ($port)
 
 setDBPassword ($password)
 
 setDBHost ($host)
 
 upper ($a_exp)
 
 lower ($a_exp)
 
 substr ($a_exp, $a_pos=1, $a_len=-1)
 
 prepareManip ($query, $types=null)
 
 prepare ($query, $types=null, $result_types=null)
 
 enableResultBuffering ($a_status)
 
 supportsSlave ()
 
 supportsFulltext ()
 
 supportsTransactions ()
 
 supports ($feature)
 
 listTables ()
 
 loadModule ($module)
 
 getAllowedAttributes ()
 
Returns
array
More...
 
 sequenceExists ($sequence)
 
 listSequences ()
 
 concat (array $values, $allow_null=true)
 
 locate ($a_needle, $a_string, $a_start_pos=1)
 
 modifyTableColumn ($table, $a_column, $a_attributes)
 
 renameTable ($a_name, $a_new_name)
 
 checkTableName ($a_name)
 
 beginTransaction ()
 
 commit ()
 
 rollback ()
 
 dropIndex ($a_table, $a_name="i1")
 
 setStorageEngine ($storage_engine)
 
 getStorageEngine ()
 
 queryCol ($query, $type=PDO::FETCH_ASSOC, $colnum=0)
 
 queryRow ($query, $types=null, $fetchmode=ilDBConstants::FETCHMODE_DEFAULT)
 
 getServerVersion ($native=false)
 
 escape ($value, $escape_wildcards=false)
 
 escapePattern ($text)
 
 migrateAllTablesToEngine ($engine=ilDBConstants::MYSQL_ENGINE_INNODB)
 
 migrateAllTablesToCollation ($collation=ilDBConstants::MYSQL_COLLATION_UTF8MB4)
 @inheritDoc More...
 
 supportsCollationMigration ()
 @inheritDoc More...
 
 supportsEngineMigration ()
 
 checkIndexName ($name)
 
 addUniqueConstraint ($table, $fields, $name="con")
 
 dropUniqueConstraint ($a_table, $a_name="con")
 
 dropUniqueConstraintByFields ($a_table, $a_fields)
 
 getLastInsertId ()
 
 buildAtomQuery ()
 
 uniqueConstraintExists ($table, array $fields)
 
 dropPrimaryKey ($table_name)
 
 executeMultiple ($stmt, $a_data)
 
 fromUnixtime ($a_expr, $a_to_text=true)
 
 unixTimestamp ()
 
 autoExecute ($tablename, $fields, $mode=ilDBConstants::AUTOQUERY_INSERT, $where=false)
 Generate an insert, update or delete query and call prepare() and execute() on it. More...
 
 getDBVersion ()
 
 sanitizeMB4StringIfNotSupported ($query)
 
Parameters
$querystring to sanitize, all MB4-Characters like emojis will re replaced with ???
Returns
string sanitized query
More...
 
 doesCollationSupportMB4Strings ()
 @inheritDoc More...
 
 groupConcat ($a_field_name, $a_seperator=",", $a_order=null)
 
Parameters
string$a_field_name
string$a_seperator
string$a_order
Returns
string
More...
 
 cast ($a_field_name, $a_dest_type)
 
Parameters
string$a_field_name
string$a_dest_type
Returns
string;
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)
 
 getServerVersion ($native=false)
 
 queryCol ($query, $type=ilDBConstants::FETCHMODE_DEFAULT, $colnum=0)
 
 queryRow ($query, $types=null, $fetchmode=ilDBConstants::FETCHMODE_DEFAULT)
 
 escape ($value, $escape_wildcards=false)
 
 escapePattern ($text)
 
 migrateAllTablesToEngine ($engine=ilDBConstants::MYSQL_ENGINE_INNODB)
 
 supportsEngineMigration ()
 
 migrateAllTablesToCollation ($collation=ilDBConstants::MYSQL_COLLATION_UTF8MB4)
 
 supportsCollationMigration ()
 
 addUniqueConstraint ($table, $fields, $name="con")
 
 dropUniqueConstraint ($table, $name="con")
 
 dropUniqueConstraintByFields ($table, $fields)
 
 checkIndexName ($name)
 
 getLastInsertId ()
 
 prepare ($query, $types=null, $result_types=null)
 
 uniqueConstraintExists ($table, array $fields)
 
 dropPrimaryKey ($table_name)
 
 executeMultiple ($stmt, $data)
 
 fromUnixtime ($expr, $to_text=true)
 
 unixTimestamp ()
 
 autoExecute ($tablename, $fields, $mode=ilDBConstants::AUTOQUERY_INSERT, $where=false)
 Generate an insert, update or delete query and call prepare() and execute() on it. More...
 
 getDBVersion ()
 returns the Version of the Database (e.g. More...
 

Data Fields

const POSTGRE_STD_PORT = 5432
 
- Data Fields inherited from ilDBPdo
const FEATURE_TRANSACTIONS = 'transactions'
 
const FEATURE_FULLTEXT = 'fulltext'
 
const FEATURE_SLAVE = 'slave'
 

Protected Member Functions

 getAdditionalAttributes ()
 
 appendLimit ($query)
 
- Protected Member Functions inherited from ilDBPdo
 initSQLMode ()
 
 getAttributes ()
 
 getAdditionalAttributes ()
 
 checkTableColumns ($a_cols)
 
 checkColumn ($a_col, $a_def)
 
 checkColumnDefinition ($a_def, $a_modify_mode=false)
 
 appendLimit ($query)
 
 autoPrepare ($table, $table_fields, $mode=ilDBConstants::AUTOQUERY_INSERT, $where=false, $types=null, $result_types=ilDBConstants::PREPARE_MANIP)
 
 buildManipSQL ($table, $table_fields, $mode, $where=false)
 

Protected Attributes

 $port = self::POSTGRE_STD_PORT
 
 $storage_engine = null
 
 $manager
 
- Protected Attributes inherited from ilDBPdo
 $host = ''
 
 $dbname = ''
 
 $charset = 'utf8'
 
 $username = ''
 
 $password = ''
 
 $port = 3306
 
 $pdo
 
 $manager
 
 $reverse
 
 $limit = null
 
 $offset = null
 
 $storage_engine = 'MyISAM'
 
 $dsn = ''
 
 $attributes
 
 $db_type = ''
 
 $error_code = 0
 
 $field_definition
 

Additional Inherited Members

- Static Public Member Functions inherited from ilDBPdo
static isReservedWord ($a_word)
 
- Static Public Member Functions inherited from ilDBInterface
static getReservedWords ()
 Get reserved words. More...
 
static isReservedWord ($a_word)
 

Detailed Description

Member Function Documentation

◆ addIndex()

ilDBPdoPostgreSQL::addIndex (   $table_name,
  $fields,
  $index_name = '',
  $fulltext = false 
)
Parameters
$table_name
array$fields
$index_name
Returns
null

Reimplemented from ilDBPdo.

Definition at line 431 of file class.ilDBPdoPostgreSQL.php.

432 {
433 $indices = $this->manager->listTableIndexes($table_name);
434 if (in_array($this->constraintName($table_name, $index_name), $indices)) {
435 return true;
436 }
437 try {
438 return parent::addIndex($table_name, $fields, $index_name, $fulltext); // TODO: Change the autogenerated stub
439 } catch (Exception $e) {
440 return true;
441 }
442 }
constraintName($a_table, $a_constraint)

References Vendor\Package\$e, and constraintName().

+ Here is the call graph for this function:

◆ addPrimaryKey()

ilDBPdoPostgreSQL::addPrimaryKey (   $table_name,
  $primary_keys 
)
Parameters
string$table_name
array$primary_keys
Returns
bool

Reimplemented from ilDBPdo.

Definition at line 417 of file class.ilDBPdoPostgreSQL.php.

418 {
419 $ilDBAnalyzer = new ilDBAnalyzer($this);
420 if ($ilDBAnalyzer->getPrimaryKeyInformation($table_name)) {
421 return true;
422 }
423 try {
424 return parent::addPrimaryKey($table_name, $primary_keys); // TODO: Change the autogenerated stub
425 } catch (Exception $e) {
426 return true;
427 }
428 }
This class gives all kind of DB information using the database manager and reverse module.

References Vendor\Package\$e.

◆ addUniqueConstraint()

ilDBPdoPostgreSQL::addUniqueConstraint (   $table,
  $fields,
  $name = "con" 
)
Parameters
$table
$fields
string$name
Returns
bool
Exceptions

ilDatabaseException

Reimplemented from ilDBPdo.

Definition at line 445 of file class.ilDBPdoPostgreSQL.php.

446 {
447 try {
448 return parent::addUniqueConstraint($table, $fields, $name); // TODO: Change the autogenerated stub
449 } catch (Exception $e) {
450 return true;
451 }
452 }
if($format !==null) $name
Definition: metadata.php:230

References Vendor\Package\$e, and $name.

◆ appendLimit()

ilDBPdoPostgreSQL::appendLimit (   $query)
protected
Parameters
$query
Returns
string

Reimplemented from ilDBPdo.

Definition at line 316 of file class.ilDBPdoPostgreSQL.php.

317 {
318 if ($this->limit !== null && $this->offset !== null) {
319 $query .= ' LIMIT ' . (int) $this->limit . ' OFFSET ' . (int) $this->offset;
320 $this->limit = null;
321 $this->offset = null;
322
323 return $query;
324 }
325
326 return $query;
327 }
$query

References ilDBPdo\$offset, and $query.

◆ connect()

ilDBPdoPostgreSQL::connect (   $return_false_for_error = false)
Parameters
bool$return_false_for_error
Returns
bool
Exceptions

Exception

Reimplemented from ilDBPdo.

Definition at line 41 of file class.ilDBPdoPostgreSQL.php.

42 {
43 $this->generateDSN();
44 try {
45 $this->pdo = new PDO($this->getDSN(), $this->getUsername(), $this->getPassword(), $this->getAttributes());
46 $this->initHelpers();
47 } catch (Exception $e) {
48 $this->error_code = $e->getCode();
49 if ($return_false_for_error) {
50 return false;
51 }
52 throw $e;
53 }
54
55 return ($this->pdo->errorCode() == PDO::ERR_NONE);
56 }

References Vendor\Package\$e, generateDSN(), ilDBPdo\getAttributes(), ilDBPdo\getDSN(), ilDBPdo\getPassword(), ilDBPdo\getUsername(), and initHelpers().

+ Here is the call graph for this function:

◆ constraintName()

ilDBPdoPostgreSQL::constraintName (   $a_table,
  $a_constraint 
)
Parameters
$a_table
$a_constraint
Returns
string

Reimplemented from ilDBPdo.

Definition at line 107 of file class.ilDBPdoPostgreSQL.php.

108 {
109 $a_constraint = str_replace($a_table . '_', '', $a_constraint);
110
111 return $a_table . '_' . $a_constraint;
112 }

Referenced by addIndex().

+ Here is the caller graph for this function:

◆ createSequence()

ilDBPdoPostgreSQL::createSequence (   $table_name,
  $start = 1 
)
Parameters
$table_name
int$start
Returns
bool

Reimplemented from ilDBPdo.

Definition at line 378 of file class.ilDBPdoPostgreSQL.php.

379 {
380 if (in_array($table_name, $this->manager->listSequences())) {
381 return true;
382 }
383 try {
384 parent::createSequence($table_name, $start); // TODO: Change the autogenerated stub
385 } catch (Exception $e) {
386 return true;
387 }
388 }

References Vendor\Package\$e.

◆ createTable()

ilDBPdoPostgreSQL::createTable (   $table_name,
  $fields,
  $drop_table = false,
  $ignore_erros = false 
)
Parameters
$table_name
$fields
bool$drop_table
bool$ignore_erros
Returns
bool|mixed
Exceptions

ilDatabaseException

Reimplemented from ilDBPdo.

Definition at line 399 of file class.ilDBPdoPostgreSQL.php.

400 {
401 if ($this->tableExists($table_name)) {
402 return true;
403 }
404 try {
405 return parent::createTable($table_name, $fields, $drop_table, $ignore_erros); // TODO: Change the autogenerated stub
406 } catch (Exception $e) {
407 return true;
408 }
409 }

References Vendor\Package\$e, and tableExists().

+ Here is the call graph for this function:

◆ dropPrimaryKey()

ilDBPdoPostgreSQL::dropPrimaryKey (   $table_name)
Parameters
$table_name
Returns
bool

Reimplemented from ilDBPdo.

Definition at line 458 of file class.ilDBPdoPostgreSQL.php.

459 {
460 return $this->manager->dropConstraint($table_name, "pk", true);
461 }

◆ dropTable()

ilDBPdoPostgreSQL::dropTable (   $table_name,
  $error_if_not_existing = false 
)
Parameters
$table_name
bool$error_if_not_existing
Returns
int

Reimplemented from ilDBPdo.

Definition at line 267 of file class.ilDBPdoPostgreSQL.php.

268 {
269 try {
270 $this->pdo->exec("DROP TABLE $table_name");
271 } catch (PDOException $PDOException) {
272 if ($error_if_not_existing) {
273 throw $PDOException;
274 }
275
276 return false;
277 }
278
279 return true;
280 }

◆ generateDSN()

ilDBPdoPostgreSQL::generateDSN ( )

Reimplemented from ilDBPdo.

Definition at line 26 of file class.ilDBPdoPostgreSQL.php.

27 {
28 if (!$this->getPort()) {
29 $this->setPort(self::POSTGRE_STD_PORT);
30 }
31 $this->dsn = 'pgsql:host=' . $this->getHost() . ';port=' . $this->getPort() . ';dbname=' . $this->getDbname() . ';user='
32 . $this->getUsername() . ';password=' . $this->getPassword() . '';
33 }
setPort($port)

References ilDBPdo\getDbname(), ilDBPdo\getHost(), ilDBPdo\getPassword(), ilDBPdo\getPort(), ilDBPdo\getUsername(), and ilDBPdo\setPort().

Referenced by connect().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAdditionalAttributes()

ilDBPdoPostgreSQL::getAdditionalAttributes ( )
protected
Returns
array

Reimplemented from ilDBPdo.

Definition at line 59 of file class.ilDBPdoPostgreSQL.php.

60 {
61 return array(
62 PDO::ATTR_EMULATE_PREPARES => true,
63 );
64 }

◆ getIndexName()

ilDBPdoPostgreSQL::getIndexName (   $index_name_base)
Parameters
$index_name_base
Returns
string

Reimplemented from ilDBPdo.

Definition at line 119 of file class.ilDBPdoPostgreSQL.php.

120 {
121 return parent::getIndexName($index_name_base); // TODO: Change the autogenerated stub
122 }

◆ getPrimaryKeyIdentifier()

ilDBPdoPostgreSQL::getPrimaryKeyIdentifier ( )

Primary key identifier.

Reimplemented from ilDBPdo.

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

79 {
80 return "pk";
81 }

◆ getStorageEngine()

ilDBPdoPostgreSQL::getStorageEngine ( )
Returns
string

Reimplemented from ilDBPdo.

Definition at line 231 of file class.ilDBPdoPostgreSQL.php.

232 {
233 return null;
234 }

◆ initHelpers()

ilDBPdoPostgreSQL::initHelpers ( )

Reimplemented from ilDBPdo.

Definition at line 67 of file class.ilDBPdoPostgreSQL.php.

68 {
69 $this->manager = new ilDBPdoManagerPostgres($this->pdo, $this);
70 $this->reverse = new ilDBPdoReversePostgres($this->pdo, $this);
71 $this->field_definition = new ilDBPdoPostgresFieldDefinition($this);
72 }
Class ilDBPdoPostgresFieldDefinition.

Referenced by connect().

+ Here is the caller graph for this function:

◆ lockTables()

ilDBPdoPostgreSQL::lockTables (   $a_tables)
Parameters
array$a_tables
Deprecated:
Use ilAtomQuery instead
Returns
bool

Reimplemented from ilDBPdo.

Definition at line 188 of file class.ilDBPdoPostgreSQL.php.

189 {
190 $locks = array();
191
192 $counter = 0;
193 foreach ($a_tables as $table) {
194 if (!isset($table['sequence']) && $table['sequence']) {
195 $lock = 'LOCK TABLE ' . $table['name'];
196
197 switch ($table['type']) {
199 $lock .= ' IN SHARE MODE ';
200 break;
201
203 $lock .= ' IN EXCLUSIVE MODE ';
204 break;
205 }
206
207 $locks[] = $lock;
208 }
209 }
210
211 // @TODO use and store a unique identifier to allow nested lock/unlocks
212 $this->beginTransaction();
213 foreach ($locks as $lock) {
214 $this->query($lock);
215 }
216
217 return true;
218 }
query($query)

References ilDBPdo\beginTransaction(), ilDBConstants\LOCK_READ, ilDBConstants\LOCK_WRITE, and ilDBPdo\query().

+ Here is the call graph for this function:

◆ nextId()

ilDBPdoPostgreSQL::nextId (   $table_name)
Parameters
string$table_name
Returns
mixed
Exceptions

ilDatabaseException

Reimplemented from ilDBPdo.

Definition at line 251 of file class.ilDBPdoPostgreSQL.php.

252 {
253 $sequence_name = $table_name . '_seq';
254 $query = "SELECT NEXTVAL('$sequence_name')";
255 $result = $this->query($query, 'integer');
256 $data = $result->fetchObject();
257
258 return $data->nextval;
259 }
$result
$data
Definition: storeScorm.php:23

References $data, $query, $result, and ilDBPdo\query().

+ Here is the call graph for this function:

◆ quoteIdentifier()

ilDBPdoPostgreSQL::quoteIdentifier (   $identifier,
  $check_option = false 
)
Parameters
$identifier
bool$check_option
Returns
mixed

Reimplemented from ilDBPdo.

Definition at line 288 of file class.ilDBPdoPostgreSQL.php.

289 {
290 return '"' . $identifier . '"';
291 }

◆ renameTable()

ilDBPdoPostgreSQL::renameTable (   $a_name,
  $a_new_name 
)
Parameters
$a_name
$a_new_name
Returns
bool
Exceptions

ilDatabaseException

Reimplemented from ilDBPdo.

Definition at line 348 of file class.ilDBPdoPostgreSQL.php.

349 {
350 // check table name
351 try {
352 $this->checkTableName($a_new_name);
353 } catch (ilDatabaseException $e) {
354 return true;
355 }
356
357 if ($this->tableExists($a_new_name)) {
358 return true;
359 }
360 try {
361 $this->manager->alterTable($a_name, [ "name" => $a_new_name ], false);
362 if ($this->sequenceExists($a_name)) {
363 $this->manager->alterTable($this->getSequenceName($a_name), [ "name" => $this->getSequenceName($a_new_name) ], false);
364 }
365 } catch (Exception $e) {
366 return true;
367 }
368
369 return true;
370 }
checkTableName($a_name)
getSequenceName($table_name)
sequenceExists($sequence)
Class ilDatabaseException.

References Vendor\Package\$e, ilDBPdo\checkTableName(), ilDBPdo\getSequenceName(), ilDBPdo\sequenceExists(), and tableExists().

+ Here is the call graph for this function:

◆ replace()

ilDBPdoPostgreSQL::replace (   $a_table,
  $a_pk_columns,
  $a_other_columns 
)
Parameters
$a_table
$a_pk_columns
$a_other_columns
Returns
bool
Exceptions

ilDatabaseException

Reimplemented from ilDBPdo.

Definition at line 132 of file class.ilDBPdoPostgreSQL.php.

133 {
134 $a_columns = array_merge($a_pk_columns, $a_other_columns);
135 $fields = array();
136 $field_values = array();
137 $placeholders = array();
138 $types = array();
139 $values = array();
140 $lobs = false;
141 $lob = array();
142 $val_field = array();
143 $a = array();
144 $b = array();
145 foreach ($a_columns as $k => $col) {
146 if ($col[0] == 'clob' or $col[0] == 'blob') {
147 $val_field[] = $this->quote($col[1], 'text') . " " . $k;
148 } else {
149 $val_field[] = $this->quote($col[1], $col[0]) . " " . $k;
150 }
151 $fields[] = $k;
152 $placeholders[] = "%s";
153 $placeholders2[] = ":$k";
154 $types[] = $col[0];
155 $values[] = $col[1];
156 $field_values[$k] = $col[1];
157 if ($col[0] == "blob" || $col[0] == "clob") {
158 $lobs = true;
159 $lob[$k] = $k;
160 }
161 $a[] = "a." . $k;
162 $b[] = "b." . $k;
163 }
164 $abpk = array();
165 $aboc = array();
166 $delwhere = array();
167 foreach ($a_pk_columns as $k => $col) {
168 $abpk[] = "a." . $k . " = b." . $k;
169 $delwhere[] = $k . " = " . $this->quote($col[1], $col[0]);
170 }
171 foreach ($a_other_columns as $k => $col) {
172 $aboc[] = "a." . $k . " = b." . $k;
173 }
174 // if ($lobs) // lobs -> use prepare execute (autoexecute broken in PEAR 2.4.1)
175 // {
176 $this->manipulate("DELETE FROM " . $a_table . " WHERE " . implode(" AND ", $delwhere));
177 $this->insert($a_table, $a_columns);
178
179 return true;
180 }
quote($value, $type=null)
manipulate($query)
insert($table_name, $values)
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples

References Vendor\Package\$a, Vendor\Package\$b, ilDBPdo\insert(), ilDBPdo\manipulate(), and ilDBPdo\quote().

+ Here is the call graph for this function:

◆ setStorageEngine()

ilDBPdoPostgreSQL::setStorageEngine (   $storage_engine)
Parameters
$storage_engine

Reimplemented from ilDBPdo.

Definition at line 237 of file class.ilDBPdoPostgreSQL.php.

238 {
239 return false;
240 }

◆ supportsFulltext()

ilDBPdoPostgreSQL::supportsFulltext ( )
Returns
bool

Reimplemented from ilDBPdo.

Definition at line 87 of file class.ilDBPdoPostgreSQL.php.

88 {
89 return false;
90 }

◆ supportsTransactions()

ilDBPdoPostgreSQL::supportsTransactions ( )
Returns
bool

Reimplemented from ilDBPdo.

Definition at line 96 of file class.ilDBPdoPostgreSQL.php.

97 {
98 return true;
99 }

◆ tableColumnExists()

ilDBPdoPostgreSQL::tableColumnExists (   $table_name,
  $column_name 
)
Parameters
$table_namestring
$column_namestring
Returns
bool

Reimplemented from ilDBPdo.

Definition at line 336 of file class.ilDBPdoPostgreSQL.php.

337 {
338 return in_array($column_name, $this->manager->listTableFields($table_name));
339 }

◆ tableExists()

ilDBPdoPostgreSQL::tableExists (   $table_name)
Parameters
string$table_name
Returns
bool

Reimplemented from ilDBPdo.

Definition at line 298 of file class.ilDBPdoPostgreSQL.php.

299 {
300 $tables = $this->listTables();
301
302 if (is_array($tables)) {
303 if (in_array($table_name, $tables)) {
304 return true;
305 }
306 }
307
308 return false;
309 }

References ilDBPdo\listTables().

Referenced by createTable(), and renameTable().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unlockTables()

ilDBPdoPostgreSQL::unlockTables ( )
Exceptions

ilDatabaseException

Deprecated:
Use ilAtomQuery instead

Reimplemented from ilDBPdo.

Definition at line 225 of file class.ilDBPdoPostgreSQL.php.

226 {
227 $this->commit();
228 }

References ilDBPdo\commit().

+ Here is the call graph for this function:

Field Documentation

◆ $manager

ilDBPdoPostgreSQL::$manager
protected

Definition at line 23 of file class.ilDBPdoPostgreSQL.php.

◆ $port

ilDBPdoPostgreSQL::$port = self::POSTGRE_STD_PORT
protected

Definition at line 15 of file class.ilDBPdoPostgreSQL.php.

◆ $storage_engine

ilDBPdoPostgreSQL::$storage_engine = null
protected

Definition at line 19 of file class.ilDBPdoPostgreSQL.php.

◆ POSTGRE_STD_PORT

const ilDBPdoPostgreSQL::POSTGRE_STD_PORT = 5432

Definition at line 11 of file class.ilDBPdoPostgreSQL.php.


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