2require_once(
'class.ilDBPdoReverse.php');
 
   31        $query = 
"SELECT a.attname AS name, 
   36                                   WHEN 'numeric' THEN (a.atttypmod / 65536) 
   37                                   WHEN 'decimal' THEN (a.atttypmod / 65536) 
   38                                   WHEN 'money'   THEN (a.atttypmod / 65536) 
   47                               WHEN 'numeric' THEN (a.atttypmod % 65536) - 4 
   48                               WHEN 'decimal' THEN (a.atttypmod % 65536) - 4 
   49                               WHEN 'money'   THEN (a.atttypmod % 65536) - 4 
   55                         (SELECT substring(pg_get_expr(d.adbin, d.adrelid) for 128) 
   57                           WHERE d.adrelid = a.attrelid 
   58                             AND d.adnum = a.attnum 
   64                   WHERE c.relname = " . $db->quote(
$table, 
'text') . 
" 
   65                     AND a.atttypid = t.oid 
   66                     AND c.oid = a.attrelid 
   67                     AND NOT a.attisdropped 
   69                     AND a.attname = " . $db->quote($field_name, 
'text') . 
" 
   77        $column = array_change_key_case($column, CASE_LOWER);
 
   78        $mapped_datatype = $db->getFieldDefinition()->mapNativeDatatype($column);
 
   80        list($types, $length, $unsigned, $fixed) = $mapped_datatype;
 
   82        if (!empty($column[
'attnotnull']) && $column[
'attnotnull'] == 
't') {
 
   86        if ($column[
'atthasdef'] === 
't' 
   87            && !preg_match(
"/nextval\('([^']+)'/", $column[
'default'])
 
   89            $default = $column[
'default'];#substr($column[
'adsrc'], 1, -1);
 
   94        $autoincrement = 
false;
 
   95        if (preg_match(
"/nextval\('([^']+)'/", $column[
'default'], $nextvals)) {
 
   96            $autoincrement = 
true;
 
   98        $definition[0] = array( 
'notnull' => $notnull, 
'nativetype' => $column[
'type'] );
 
   99        if (!is_null($length)) {
 
  100            $definition[0][
'length'] = $length;
 
  102        if (!is_null($unsigned)) {
 
  103            $definition[0][
'unsigned'] = $unsigned;
 
  105        if (!is_null($fixed)) {
 
  106            $definition[0][
'fixed'] = $fixed;
 
  109            $definition[0][
'default'] = 
$default;
 
  111        if ($autoincrement !== 
false) {
 
  112            $definition[0][
'autoincrement'] = $autoincrement;
 
  115            $definition[
$key] = $definition[0];
 
  117                unset($definition[
$key][
'default']);
 
  141        $query = 
'SELECT relname, indkey FROM pg_index, pg_class';
 
  142        $query .= 
' WHERE pg_class.oid = pg_index.indexrelid';
 
  143        $query .= 
" AND indisunique != 't' AND indisprimary != 't'";
 
  144        $query .= 
' AND pg_class.relname = %s';
 
  145        $index_name_mdb2 = $db->getIndexName($index_name);
 
  149        } 
catch (Exception $e) {
 
  160        $row = array_change_key_case(
$row, CASE_LOWER);
 
  164        $definition = array();
 
  166        $index_column_numbers = explode(
' ', 
$row[
'indkey']);
 
  169        foreach ($index_column_numbers as $number) {
 
  170            $definition[
'fields'][
$columns[($number - 1)]] = array(
 
  171                'position' => $colpos++,
 
  172                'sorting' => 
'ascending',
 
  193        $query = 
'SELECT relname, indisunique, indisprimary, indkey FROM pg_index, pg_class';
 
  194        $query .= 
' WHERE pg_class.oid = pg_index.indexrelid';
 
  195        $query .= 
" AND (indisunique = 't' OR indisprimary = 't')";
 
  196        $query .= 
' AND pg_class.relname = %s';
 
  197        $constraint_name_mdb2 = $db->getIndexName($constraint_name);
 
  200        } 
catch (Exception $e) {
 
  203        if ($e instanceof PDOException || empty(
$row)) {
 
  212        $row = array_change_key_case(
$row, CASE_LOWER);
 
  215        $definition = array();
 
  216        if (
$row[
'indisprimary'] == 
't') {
 
  217            $definition[
'primary'] = 
true;
 
  218        } elseif (
$row[
'indisunique'] == 
't') {
 
  219            $definition[
'unique'] = 
true;
 
  222        $index_column_numbers = explode(
' ', 
$row[
'indkey']);
 
  225        foreach ($index_column_numbers as $number) {
 
  226            $definition[
'fields'][
$columns[($number - 1)]] = array(
 
  227                'position' => $colpos++,
 
  228                'sorting' => 
'ascending',
 
  256        $query = 
"SELECT trg.tgname AS trigger_name, 
  257                         tbl.relname AS table_name, 
  259                            WHEN p.proname IS NOT NULL THEN 'EXECUTE PROCEDURE ' || p.proname || '();' 
  262                         CASE trg.tgtype & cast(2 as int2) 
  266                         CASE trg.tgtype & cast(28 as int2) 
  267                            WHEN 16 THEN 'UPDATE' 
  270                            WHEN 20 THEN 'INSERT, UPDATE' 
  271                            WHEN 28 THEN 'INSERT, UPDATE, DELETE' 
  272                            WHEN 24 THEN 'UPDATE, DELETE' 
  273                            WHEN 12 THEN 'INSERT, DELETE' 
  274                         END AS trigger_event, 
  275                         trg.tgenabled AS trigger_enabled, 
  276                         obj_description(trg.oid, 'pg_trigger') AS trigger_comment 
  280                   WHERE trg.tgrelid = tbl.oid 
  281                     AND trg.tgfoid = p.oid 
  282                     AND trg.tgname = " . $db->quote($trigger, 
'text');
 
  284            'trigger_name' => 
'text',
 
  285            'table_name' => 
'text',
 
  286            'trigger_body' => 
'text',
 
  287            'trigger_type' => 
'text',
 
  288            'trigger_event' => 
'text',
 
  289            'trigger_comment' => 
'text',
 
  290            'trigger_enabled' => 
'boolean',
 
An exception for terminatinating execution or to throw for unit testing.
getTriggerDefinition($trigger)
Get the structure of a trigger into an array.
getTableConstraintDefinition($table, $constraint_name)
Get the structure of a constraint into an array.
getTableIndexDefinition($table, $index_name)
getTableFieldDefinition($table_name, $field_name)
Class ilDatabaseException.
if(empty($password)) $table