3 require_once(
'./Services/Database/classes/PDO/Manager/class.ilDBPdoManagerPostgres.php');
4 require_once(
'class.ilDBPdo.php');
5 require_once(
'./Services/Database/classes/PDO/FieldDefinition/class.ilDBPdoPostgresFieldDefinition.php');
6 require_once(
'./Services/Database/classes/PDO/Reverse/class.ilDBPdoReversePostgres.php');
19 protected $port = self::POSTGRE_STD_PORT;
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)
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) {
200 if (!isset($table[
'sequence']) && $table[
'sequence']) {
201 $lock =
'LOCK TABLE ' . $table[
'name'];
203 switch ($table[
'type']) {
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);
383 if (in_array($table_name, $this->manager->listSequences())) {
387 parent::createSequence($table_name, $start);
402 public function createTable($table_name, $fields, $drop_table =
false, $ignore_erros =
false)
408 return parent::createTable($table_name, $fields, $drop_table, $ignore_erros);
422 require_once(
'./Services/Database/classes/class.ilDBAnalyzer.php');
424 if ($ilDBAnalyzer->getPrimaryKeyInformation($table_name)) {
428 return parent::addPrimaryKey($table_name, $primary_keys);
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);
452 return parent::addUniqueConstraint(
$table, $fields,
$name);
464 return $this->manager->dropConstraint($table_name,
"pk",
true);
createTable($table_name, $fields, $drop_table=false, $ignore_erros=false)
dropTable($table_name, $error_if_not_existing=false)
renameTable($a_name, $a_new_name)
Class ilDBPdoPostgresFieldDefinition.
quote($value, $type=null)
getPrimaryKeyIdentifier()
Primary key identifier.
setStorageEngine($storage_engine)
Class ilDatabaseException.
replace($a_table, $a_pk_columns, $a_other_columns)
constraintName($a_table, $a_constraint)
quoteIdentifier($identifier, $check_option=false)
tableColumnExists($table_name, $column_name)
dropPrimaryKey($table_name)
addPrimaryKey($table_name, $primary_keys)
addIndex($table_name, $fields, $index_name='', $fulltext=false)
Create styles array
The data for the language used.
createSequence($table_name, $start=1)
getIndexName($index_name_base)
getAdditionalAttributes()
insert($table_name, $values)
addUniqueConstraint($table, $fields, $name="con")
if(empty($password)) $table
This class gives all kind of DB information using the MDB2 manager and reverse module.
connect($return_false_for_error=false)