3require_once(
'./Services/Database/classes/PDO/Manager/class.ilDBPdoManagerPostgres.php');
 
    4require_once(
'class.ilDBPdo.php');
 
    5require_once(
'./Services/Database/classes/PDO/FieldDefinition/class.ilDBPdoPostgresFieldDefinition.php');
 
    6require_once(
'./Services/Database/classes/PDO/Reverse/class.ilDBPdoReversePostgres.php');
 
   33            $this->
setPort(self::POSTGRE_STD_PORT);
 
   35        $this->dsn = 
'pgsql:host=' . $this->
getHost() . 
';port=' . $this->
getPort() . 
';dbname=' . $this->
getDbname() . 
';user=' 
   45    public function connect($return_false_for_error = 
false)
 
   51        } 
catch (Exception $e) {
 
   52            $this->error_code = $e->getCode();
 
   53            if ($return_false_for_error) {
 
   59        return ($this->pdo->errorCode() == PDO::ERR_NONE);
 
   66            PDO::ATTR_EMULATE_PREPARES => 
true,
 
  113        $a_constraint = str_replace($a_table . 
'_', 
'', $a_constraint);
 
  115        return $a_table . 
'_' . $a_constraint;
 
  125        return parent::getIndexName($index_name_base); 
 
  136    public function replace($a_table, $a_pk_columns, $a_other_columns)
 
  138        $a_columns = array_merge($a_pk_columns, $a_other_columns);
 
  140        $field_values = array();
 
  141        $placeholders = array();
 
  146        $val_field = array();
 
  149        foreach ($a_columns as $k => $col) {
 
  150            if ($col[0] == 
'clob' or $col[0] == 
'blob') {
 
  151                $val_field[] = $this->
quote($col[1], 
'text') . 
" " . $k;
 
  153                $val_field[] = $this->
quote($col[1], $col[0]) . 
" " . $k;
 
  156            $placeholders[] = 
"%s";
 
  157            $placeholders2[] = 
":$k";
 
  160            $field_values[$k] = $col[1];
 
  161            if ($col[0] == 
"blob" || $col[0] == 
"clob") {
 
  171        foreach ($a_pk_columns as $k => $col) {
 
  172            $abpk[] = 
"a." . $k . 
" = b." . $k;
 
  173            $delwhere[] = $k . 
" = " . $this->
quote($col[1], $col[0]);
 
  175        foreach ($a_other_columns as $k => $col) {
 
  176            $aboc[] = 
"a." . $k . 
" = b." . $k;
 
  180        $this->
manipulate(
"DELETE FROM " . $a_table . 
" WHERE " . implode($delwhere, 
" AND "));
 
  181        $this->
insert($a_table, $a_columns);
 
  199        foreach ($a_tables as 
$table) {
 
  201                $lock = 
'LOCK TABLE ' . 
$table[
'name'];
 
  205                        $lock .= 
' IN SHARE MODE ';
 
  209                        $lock .= 
' IN EXCLUSIVE MODE ';
 
  219        foreach ($locks as $lock) {
 
  259        $sequence_name = $table_name . 
'_seq';
 
  260        $query = 
"SELECT NEXTVAL('$sequence_name')";
 
  264        return $data->nextval;
 
  273    public function dropTable($table_name, $error_if_not_existing = 
false)
 
  276            $this->pdo->exec(
"DROP TABLE $table_name");
 
  277        } 
catch (PDOException $PDOException) {
 
  278            if ($error_if_not_existing) {
 
  296        return '"' . $identifier . 
'"';
 
  308        if (is_array($tables)) {
 
  309            if (in_array($table_name, $tables)) {
 
  324        if ($this->limit !== 
null && $this->offset !== 
null) {
 
  327            $this->offset = 
null;
 
  344        return in_array($column_name, $this->manager->listTableFields($table_name));
 
  367            $this->manager->alterTable($a_name, array( 
"name" => $a_new_name ), 
false);
 
  368        } 
catch (Exception $e) {
 
  383        if (in_array($table_name, $this->manager->listSequences())) {
 
  387            parent::createSequence($table_name, $start); 
 
  388        } 
catch (Exception $e) {
 
  402    public function createTable($table_name, $fields, $drop_table = 
false, $ignore_erros = 
false)
 
  408            return parent::createTable($table_name, $fields, $drop_table, $ignore_erros); 
 
  409        } 
catch (Exception $e) {
 
  422        require_once(
'./Services/Database/classes/class.ilDBAnalyzer.php');
 
  424        if ($ilDBAnalyzer->getPrimaryKeyInformation($table_name)) {
 
  428            return parent::addPrimaryKey($table_name, $primary_keys); 
 
  429        } 
catch (Exception $e) {
 
  435    public function addIndex($table_name, $fields, $index_name = 
'', $fulltext = 
false)
 
  437        $indices = $this->manager->listTableIndexes($table_name);
 
  438        if (in_array($this->
constraintName($table_name, $index_name), $indices)) {
 
  442            return parent::addIndex($table_name, $fields, $index_name, $fulltext); 
 
  443        } 
catch (Exception $e) {
 
  452            return parent::addUniqueConstraint(
$table, $fields, 
$name); 
 
  453        } 
catch (Exception $e) {
 
  464        return $this->manager->dropConstraint($table_name, 
"pk", 
true);
 
An exception for terminatinating execution or to throw for unit testing.
This class gives all kind of DB information using the MDB2 manager and reverse module.
getPrimaryKeyIdentifier()
Primary key identifier.
tableColumnExists($table_name, $column_name)
constraintName($a_table, $a_constraint)
quoteIdentifier($identifier, $check_option=false)
replace($a_table, $a_pk_columns, $a_other_columns)
addIndex($table_name, $fields, $index_name='', $fulltext=false)
renameTable($a_name, $a_new_name)
dropPrimaryKey($table_name)
dropTable($table_name, $error_if_not_existing=false)
setStorageEngine($storage_engine)
createSequence($table_name, $start=1)
connect($return_false_for_error=false)
addPrimaryKey($table_name, $primary_keys)
addUniqueConstraint($table, $fields, $name="con")
createTable($table_name, $fields, $drop_table=false, $ignore_erros=false)
getIndexName($index_name_base)
getAdditionalAttributes()
Class ilDBPdoPostgresFieldDefinition.
quote($value, $type=null)
insert($table_name, $values)
Class ilDatabaseException.
if(empty($password)) $table