2 require_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') .
" 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'])
90 if (is_null($default) && $notnull) {
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;
108 if ($default !==
false) {
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);
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) {
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);
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) {
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',
320 return parent::tableInfo(
$result, $mode);
326 if (!is_resource($resource)) {
330 if ($db->options[
'portability']) {
331 if ($db->options[
'field_case'] == CASE_LOWER) {
332 $case_func =
'strtolower';
334 $case_func =
'strtoupper';
337 $case_func =
'strval';
340 $count = @pg_num_fields($resource);
344 $res[
'num_fields'] = $count;
347 $db->loadModule(
'Datatype', null,
true);
348 for (
$i = 0;
$i < $count;
$i++) {
350 'table' => function_exists(
'pg_field_table') ? @pg_field_table($resource,
$i) :
'',
351 'name' => $case_func(@pg_field_name($resource,
$i)),
352 'type' => @pg_field_type($resource,
$i),
353 'length' => @pg_field_size($resource,
$i),
356 $mdb2type_info = $db->datatype->mapNativeDatatype(
$res[
$i]);
358 return $mdb2type_info;
360 $res[
$i][
'mdb2type'] = $mdb2type_info[0][0];
const MDB2_FETCHMODE_ASSOC
Column data indexed by column names.
getTableFieldDefinition($table_name, $field_name)
const MDB2_TABLEINFO_ORDER
These are constants for the tableInfo-function they are bitwised or'ed.
getTableIndexDefinition($table, $index_name)
Class ilDatabaseException.
getTriggerDefinition($trigger)
Get the structure of a trigger into an array.
foreach($_POST as $key=> $value) $res
const MDB2_TABLEINFO_ORDERTABLE
const MDB2_ERROR_NEED_MORE_DATA
isResultCommon($value)
Tell whether a value is a MDB2 result implementing the common interface.
tableInfo($result, $mode=null)
Returns information about a table or a result set.
Create styles array
The data for the language used.
getTableConstraintDefinition($table, $constraint_name)
Get the structure of a constraint into an array.
if(empty($password)) $table
isError($data, $code=null)
Tell whether a value is a PEAR error.