How can I get column type?
I have tried pg_field_type PHP function and information_schema. Both seem not to work.
$link = pg_connect('host='.$db[$active_db]['host'].' user='.$db[$active_db]['username'].' password='.$db[$active_db]['password'].' dbname='.$db[$active_db]['db'].' connect_timeout=5');
if ($link) {
$result = pg_query($link, "select a.attname from pg_attribute a, pg_class b where b.relfilenode=a.attrelid and b.relname='".$form_state['values']['query']."' and a.attname not in ('tableoid','cmax','xmax','cmin''xmin','ctid')");
while ($row = pg_fetch_row($result)) {
$schema[] = $row;
}
foreach($schema as $k => $s) {
$result = pg_query($link, "select ".$s[0]." from '".$form_state['values']['query']."'");
$schema[$k][1] = pg_field_type($result, 0);
}
pg_close($link);
}