Jump to content

Column type


ram4nd

Recommended Posts

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);
    }

Link to comment
https://forums.phpfreaks.com/topic/257198-column-type/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.