ram4nd Posted February 17, 2012 Share Posted February 17, 2012 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); } Quote Link to comment https://forums.phpfreaks.com/topic/257198-column-type/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.