note 79127 added to function.pg-meta-data
| From: | jsnell at e-normous dot com | Date: | Mon, 12 Nov 2007 23:24:01 +0000 |
| Subject: | note 79127 added to function.pg-meta-data | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-132212@lists.php.net to get a copy of this message | ||
The built in function does not provide any support for selecting a schema. If you need schema
support and do not want to alter your SEARCH_PATH, the following function can provide it:
function meta_data($table, $schema = 'public')
{
$result = pg_query_params("SELECT a.attname, a.attnum, t.typname, a.attlen, a.attnotNULL,
a.atthasdef, a.attndims
FROM pg_class as c, pg_attribute a, pg_type t, pg_namespace n
WHERE a.attnum > 0
AND a.attrelid = c.oid
AND c.relname = $1
AND a.atttypid = t.oid
AND n.oid = c.relnamespace
AND n.nspname = $2
ORDER BY a.attnum", array($table, $schema));
$fields = array();
while($row = pg_fetch_array()) {
$fields['attname'] = $row;
}
return $fields;
}
----
Server IP: 208.69.120.35
Probable Submitter: 216.145.226.130
----
Manual Page -- http://www.php.net/manual/en/function.pg-meta-data.php
Edit -- https://master.php.net/note/edit/79127
Del: integrated -- https://master.php.net/note/delete/79127/integrated
Del: useless -- https://master.php.net/note/delete/79127/useless
Del: bad code -- https://master.php.net/note/delete/79127/bad+code
Del: spam -- https://master.php.net/note/delete/79127/spam
Del: non-english -- https://master.php.net/note/delete/79127/non-english
Del: in docs -- https://master.php.net/note/delete/79127/in+docs
Del: other reasons-- https://master.php.net/note/delete/79127
Reject -- https://master.php.net/note/reject/79127
Search -- https://master.php.net/manage/user-notes.php