From: | Steven Klassen <sklassen(at)commandprompt(dot)com> |
---|---|
To: | Miles Keaton <mileskeaton(at)gmail(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: list fieldnames in table? (from PHP) |
Date: | 2004-10-26 03:53:33 |
Message-ID: | 20041026035329.GB23780@commandprompt.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
* Miles Keaton <mileskeaton(at)gmail(dot)com> [2004-10-25 19:36:43 -0700]:
> Is there a simple way to list fieldnames in a table, from PHP?
>
> When on the command-line, I just do \d tablename
>
> But how to get the fieldnames from PHP commands?
If your namespace is 'public' and your table is 'users', for example:
SELECT attname
FROM pg_namespace, pg_attribute, pg_type, pg_class
WHERE pg_type.oid = atttypid
AND pg_class.oid = attrelid
AND pg_namespace.nspname = 'public'
AND relnamespace = pg_namespace.oid
AND relname = 'users'
AND attnum >= 1;
--
Steven Klassen - Lead Programmer
Command Prompt, Inc. - http://www.commandprompt.com/
PostgreSQL Replication & Support Services, (503) 667-4564
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Fuhr | 2004-10-26 04:04:39 | Re: list fieldnames in table? (from PHP) |
Previous Message | Mayra | 2004-10-26 03:40:05 | Theory!! |