note 44666 added to function.pg-field-name

From: Date: Thu, 12 Aug 2004 17:01:21 +0000
Subject: note 44666 added to function.pg-field-name
Groups: php.notes 
Request: Send a blank email to php-notes+get-74542@lists.php.net to get a copy of this message
In fact you can extract the size of the varchar field, by simply sending the following query: "select a.atttypmod,a.attrelid from pg_attribute as a, pg_class as c where c.relname='$table' AND a.attrelid=c.oid AND a.attname='$field'" here is a simple function that does that: function get_field_size($table, $field, $link) { $result = pg_query($link, "select a.atttypmod,a.attrelid from pg_attribute as a, pg_class as c where c.relname='$table' AND a.attrelid=c.oid AND a.attname='$field'"); $data = pg_fetch_object($result); return ($data->atttypmod - 4); } returned value is a size of a given field (also varchar) ---- Manual Page -- http://www.php.net/manual/en/function.pg-field-name.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+44666 Delete -- http://master.php.net/manage/user-notes.php?action=delete+44666&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+44666&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#74542) next »