postgresql field size information

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I need to get the size of the fields defined in a postgresql table for
use in my PHP script.

For instance:

$fieldname = pg_field_name($stat,$i);
$size = pg_field_size($stat,$i);
$type = pg_field_type($stat,$i);

I tried using pg_field_size but for char type fields it returns a -1
indicating the field is variable length.  I need to get the defined size
of the field.  

pg_field_prtlen does not appear to be the correct function to return
this type of information.

I did get most of what I needed from this query:

$stat = pg_query($dbh,"select attname,atttypmod from pg_class c join
pg_attribute a on c.oid = a.attrelid where c.relname = '$tablename' and
a.attnum >= 0");

But the atttypmod field appears to have some overhead included (4
bytes).  I can adjust for that but there must be an easier way to get
the information for a field defined in a table.

Suggestions on how to do this?

-- 
Scot L. Harris <webid@xxxxxxxxxx>

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux