Re: list fieldnames in table? (from PHP)

Поиск
Список
Период
Сортировка
От Steven Klassen
Тема Re: list fieldnames in table? (from PHP)
Дата
Msg-id 20041026035329.GB23780@commandprompt.com
обсуждение исходный текст
Ответ на list fieldnames in table? (from PHP)  (Miles Keaton <mileskeaton@gmail.com>)
Список pgsql-general
* Miles Keaton <mileskeaton@gmail.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

В списке pgsql-general по дате отправления:

Предыдущее
От: "Mayra"
Дата:
Сообщение: Theory!!
Следующее
От: Michael Fuhr
Дата:
Сообщение: Re: list fieldnames in table? (from PHP)