ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 434 of file class.ilDBPdoPostgreSQL.php.

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

References 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 419 of file class.ilDBPdoPostgreSQL.php.

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

◆ addUniqueConstraint()

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

ilDatabaseException

Reimplemented from ilDBPdo.

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

449 {
450 try {
451 return parent::addUniqueConstraint($table, $fields, $name); // TODO: Change the autogenerated stub
452 } catch (Exception $e) {
453 return true;
454 }
455 }
if(empty($password)) $table
Definition: pwgen.php:24

References $name, and $table.

◆ appendLimit()

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

Reimplemented from ilDBPdo.

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

322 {
323 if ($this->limit !== null && $this->offset !== null) {
324 $query .= ' LIMIT ' . (int) $this->limit . ' OFFSET ' . (int) $this->offset;
325 $this->limit = null;
326 $this->offset = null;
327
328 return $query;
329 }
330
331 return $query;
332 }
$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 45 of file class.ilDBPdoPostgreSQL.php.

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

References 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 112 of file class.ilDBPdoPostgreSQL.php.

113 {
114 $a_constraint = str_replace($a_table . '_', '', $a_constraint);
115
116 return $a_table . '_' . $a_constraint;
117 }

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 380 of file class.ilDBPdoPostgreSQL.php.

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

References $start.

◆ 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 401 of file class.ilDBPdoPostgreSQL.php.

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

References 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 461 of file class.ilDBPdoPostgreSQL.php.

462 {
463 return $this->manager->dropConstraint($table_name, "pk", true);
464 }

◆ 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 272 of file class.ilDBPdoPostgreSQL.php.

273 {
274 try {
275 $this->pdo->exec("DROP TABLE $table_name");
276 } catch (PDOException $PDOException) {
277 if ($error_if_not_existing) {
278 throw $PDOException;
279 }
280
281 return false;
282 }
283
284 return true;
285 }

◆ generateDSN()

ilDBPdoPostgreSQL::generateDSN ( )

Reimplemented from ilDBPdo.

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

31 {
32 if (!$this->getPort()) {
33 $this->setPort(self::POSTGRE_STD_PORT);
34 }
35 $this->dsn = 'pgsql:host=' . $this->getHost() . ';port=' . $this->getPort() . ';dbname=' . $this->getDbname() . ';user='
36 . $this->getUsername() . ';password=' . $this->getPassword() . '';
37 }
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 63 of file class.ilDBPdoPostgreSQL.php.

64 {
65 return array(
66 PDO::ATTR_EMULATE_PREPARES => true,
67 PDO::ATTR_STRINGIFY_FETCHES => true,
68 );
69 }

◆ getIndexName()

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

Reimplemented from ilDBPdo.

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

125 {
126 return parent::getIndexName($index_name_base); // TODO: Change the autogenerated stub
127 }

◆ getPrimaryKeyIdentifier()

ilDBPdoPostgreSQL::getPrimaryKeyIdentifier ( )

Primary key identifier.

Reimplemented from ilDBPdo.

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

84 {
85 return "pk";
86 }

◆ getStorageEngine()

ilDBPdoPostgreSQL::getStorageEngine ( )
Returns
string

Reimplemented from ilDBPdo.

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

237 {
238 return null;
239 }

◆ initHelpers()

ilDBPdoPostgreSQL::initHelpers ( )

Reimplemented from ilDBPdo.

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

73 {
74 $this->manager = new ilDBPdoManagerPostgres($this->pdo, $this);
75 $this->reverse = new ilDBPdoReversePostgres($this->pdo, $this);
76 $this->field_definition = new ilDBPdoPostgresFieldDefinition($this);
77 }
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 193 of file class.ilDBPdoPostgreSQL.php.

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

References $table, 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 256 of file class.ilDBPdoPostgreSQL.php.

257 {
258 $sequence_name = $table_name . '_seq';
259 $query = "SELECT NEXTVAL('$sequence_name')";
260 $result = $this->query($query, 'integer');
261 $data = $result->fetchObject();
262
263 return $data->nextval;
264 }
$result
$data
Definition: bench.php:6

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 293 of file class.ilDBPdoPostgreSQL.php.

294 {
295 return '"' . $identifier . '"';
296 }

◆ renameTable()

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

ilDatabaseException

Reimplemented from ilDBPdo.

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

354 {
355 // check table name
356 try {
357 $this->checkTableName($a_new_name);
358 } catch (ilDatabaseException $e) {
359 return true;
360 }
361
362 if ($this->tableExists($a_new_name)) {
363 return true;
364 }
365 try {
366 $this->manager->alterTable($a_name, array( "name" => $a_new_name ), false);
367 } catch (Exception $e) {
368 return true;
369 }
370
371 return true;
372 }
checkTableName($a_name)
Class ilDatabaseException.

References ilDBPdo\checkTableName(), 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 137 of file class.ilDBPdoPostgreSQL.php.

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

References $values, 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 242 of file class.ilDBPdoPostgreSQL.php.

243 {
244 return false;
245 }

◆ supportsFulltext()

ilDBPdoPostgreSQL::supportsFulltext ( )
Returns
bool

Reimplemented from ilDBPdo.

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

93 {
94 return false;
95 }

◆ supportsTransactions()

ilDBPdoPostgreSQL::supportsTransactions ( )
Returns
bool

Reimplemented from ilDBPdo.

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

102 {
103 return true;
104 }

◆ tableColumnExists()

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

Reimplemented from ilDBPdo.

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

342 {
343 return in_array($column_name, $this->manager->listTableFields($table_name));
344 }

◆ tableExists()

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

Reimplemented from ilDBPdo.

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

304 {
305 $tables = $this->listTables();
306
307 if (is_array($tables)) {
308 if (in_array($table_name, $tables)) {
309 return true;
310 }
311 }
312
313 return false;
314 }

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 230 of file class.ilDBPdoPostgreSQL.php.

231 {
232 $this->commit();
233 }

References ilDBPdo\commit().

+ Here is the call graph for this function:

Field Documentation

◆ $manager

ilDBPdoPostgreSQL::$manager
protected

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

◆ $port

ilDBPdoPostgreSQL::$port = self::POSTGRE_STD_PORT
protected

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

◆ $storage_engine

ilDBPdoPostgreSQL::$storage_engine = null
protected

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

◆ POSTGRE_STD_PORT

const ilDBPdoPostgreSQL::POSTGRE_STD_PORT = 5432

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


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