ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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::MDB2_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)
 
 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)
 
 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)
 
 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::MDB2_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::MDB2_AUTOQUERY_INSERT, $where=false, $types=null, $result_types=ilDBConstants::MDB2_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 411 of file class.ilDBPdoPostgreSQL.php.

411 {
412 $indices = $this->manager->listTableIndexes($table_name);
413 if (in_array($this->constraintName($table_name, $index_name), $indices)) {
414 return true;
415 }
416 try {
417 return parent::addIndex($table_name, $fields, $index_name, $fulltext); // TODO: Change the autogenerated stub
418 } catch (Exception $e) {
419 return true;
420 }
421 }
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 397 of file class.ilDBPdoPostgreSQL.php.

397 {
398 require_once('./Services/Database/classes/class.ilDBAnalyzer.php');
399 $ilDBAnalyzer = new ilDBAnalyzer($this);
400 if ($ilDBAnalyzer->getPrimaryKeyInformation($table_name)) {
401 return true;
402 }
403 try {
404 return parent::addPrimaryKey($table_name, $primary_keys); // TODO: Change the autogenerated stub
405 } catch (Exception $e) {
406 return true;
407 }
408 }
This class gives all kind of DB information using the MDB2 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 424 of file class.ilDBPdoPostgreSQL.php.

424 {
425 try {
426 return parent::addUniqueConstraint($table, $fields, $name); // TODO: Change the autogenerated stub
427 } catch (Exception $e) {
428 return true;
429 }
430 }

◆ appendLimit()

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

Reimplemented from ilDBPdo.

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

304 {
305 if ($this->limit !== null && $this->offset !== null) {
306 $query .= ' LIMIT ' . (int)$this->limit . ' OFFSET ' . (int)$this->offset;
307 $this->limit = null;
308 $this->offset = null;
309
310 return $query;
311 }
312
313 return $query;
314 }

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

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

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

104 {
105 $a_constraint = str_replace($a_table . '_', '', $a_constraint);
106
107 return $a_table . '_' . $a_constraint;
108 }

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

360 {
361 if (in_array($table_name, $this->manager->listSequences())) {
362 return true;
363 }
364 try {
365 parent::createSequence($table_name, $start); // TODO: Change the autogenerated stub
366 } catch (Exception $e) {
367 return true;
368 }
369 }

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

380 {
381 if ($this->tableExists($table_name)) {
382 return true;
383 }
384 try {
385 return parent::createTable($table_name, $fields, $drop_table, $ignore_erros); // TODO: Change the autogenerated stub
386 } catch (Exception $e) {
387 return true;
388 }
389 }

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

436 {
437 return $this->manager->dropConstraint($table_name, "pk", true);
438 }

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

258 {
259 try {
260 $this->pdo->exec("DROP TABLE $table_name");
261 } catch (PDOException $PDOException) {
262 if ($error_if_not_existing) {
263 throw $PDOException;
264 }
265
266 return false;
267 }
268
269 return true;
270 }

◆ generateDSN()

ilDBPdoPostgreSQL::generateDSN ( )

Reimplemented from ilDBPdo.

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

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

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

◆ getIndexName()

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

Reimplemented from ilDBPdo.

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

115 {
116 return parent::getIndexName($index_name_base); // TODO: Change the autogenerated stub
117 }

◆ getPrimaryKeyIdentifier()

ilDBPdoPostgreSQL::getPrimaryKeyIdentifier ( )

Primary key identifier.

Reimplemented from ilDBPdo.

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

78 {
79 return "pk";
80 }

◆ getStorageEngine()

ilDBPdoPostgreSQL::getStorageEngine ( )
Returns
string

Reimplemented from ilDBPdo.

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

225 {
226 return null;
227 }

◆ initHelpers()

ilDBPdoPostgreSQL::initHelpers ( )

Reimplemented from ilDBPdo.

Definition at line 68 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 182 of file class.ilDBPdoPostgreSQL.php.

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

References $counter, $ilLog, 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 243 of file class.ilDBPdoPostgreSQL.php.

243 {
244 $sequence_name = $table_name . '_seq';
245 $query = "SELECT NEXTVAL('$sequence_name')";
246 $result = $this->query($query, 'integer');
247 $data = $result->fetchObject();
248
249 return $data->nextval;
250 }
$result

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

278 {
279 return '"'.$identifier.'"';
280 }

◆ renameTable()

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

ilDatabaseException

Reimplemented from ilDBPdo.

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

334 {
335 // check table name
336 try {
337 $this->checkTableName($a_new_name);
338 } catch (ilDatabaseException $e) {
339 return true;
340 }
341
342 if ($this->tableExists($a_new_name)) {
343 return true;
344 }
345 try {
346 $this->manager->alterTable($a_name, array( "name" => $a_new_name ), false);
347 } catch (Exception $e) {
348 return true;
349 }
350
351 return true;
352 }
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 127 of file class.ilDBPdoPostgreSQL.php.

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

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

230 {
231 return false;
232 }

◆ supportsFulltext()

ilDBPdoPostgreSQL::supportsFulltext ( )
Returns
bool

Reimplemented from ilDBPdo.

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

86 {
87 return false;
88 }

◆ supportsTransactions()

ilDBPdoPostgreSQL::supportsTransactions ( )
Returns
bool

Reimplemented from ilDBPdo.

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

94 {
95 return true;
96 }

◆ tableColumnExists()

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

Reimplemented from ilDBPdo.

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

323 {
324 return in_array($column_name, $this->manager->listTableFields($table_name));
325 }

◆ tableExists()

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

Reimplemented from ilDBPdo.

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

287 {
288 $tables = $this->listTables();
289
290 if (is_array($tables)) {
291 if (in_array($table_name, $tables)) {
292 return true;
293 }
294 }
295
296 return false;
297 }

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

220 {
221 $this->commit();
222 }

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: