6 private $name, $tablename, $type, $nullable, $max_length, $deferred, $deferrable, $conname,
20 pg_get_expr(adbin, adrelid) AS adsrc,
21 COALESCE(condeferred,
'f') AS deferred,
22 COALESCE(condeferrable,
'f') AS deferrable,
23 CASE WHEN typname =
'int2' THEN
'smallint'
24 WHEN typname =
'int4' THEN
'integer'
25 WHEN typname =
'int8' THEN
'bigint'
26 WHEN typname =
'bpchar' THEN
'char'
27 ELSE typname END AS typname
29JOIN pg_namespace
n ON (
n.oid = c.relnamespace)
30JOIN pg_attribute a ON (a.attrelid = c.oid)
31JOIN pg_type t ON (t.oid = a.atttypid)
32LEFT JOIN pg_constraint o ON (o.conrelid = c.oid AND a.attnum = ANY(o.conkey) AND o.contype =
'f')
33LEFT JOIN pg_attrdef d on c.oid=d.adrelid and a.attnum=d.adnum
49 $row =
$res->fetchObject();
54 $n->
type = $row->typname;
55 $n->nullable = ( $row->attnotnull ==
'f' );
57 $n->tablename = $table;
58 $n->max_length = $row->attlen;
59 $n->deferrable = ( $row->deferrable ==
't' );
60 $n->deferred = ( $row->deferred ==
't' );
61 $n->conname = $row->conname;
62 $n->has_default = ( $row->atthasdef ===
't' );
63 $n->default = $row->adsrc;