Re: How can I get metadate of a table in PHP3?

Re: How can I get metadate of a table in PHP3?

am 02.09.2002 00:22:19 von Zhidian Du

--------------000801030606030008010207
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 8bit

My meaning is how can I get all the fields name of a table?

ID Name Age ....
1 John 20
2 Smith 23
......

Get ID, Name and Age and so on.





knut.suebert@web.de wrote:

>Zhidian Du schrieb:
>
>
>
>>How can I get metadate of a table in PHP3?
>>
>>
>
>If you think about things like the output of "\d tablename", turn on
>the logging of queries, do a "\d tablename" and watch the
>logfiles.
>
>Somewhere I need the fieldtypes of a table named $this->table, the
>query is
>
> $q = "SELECT a.attname, format_type(a.atttypid, a.atttypmod)
> FROM pg_class c, pg_attribute a
> WHERE c.relname = '".$this->table."'
> AND a.attnum > 0 AND a.attrelid = c.oid
> ORDER BY a.attnum";
>
>which is stolen from the logs - I'll never understand it ;)
>
>Greetings,
>Knut Sübert
>
>---------------------------(end of broadcast)---------------------------
>TIP 6: Have you searched our list archives?
>
>http://archives.postgresql.org
>
>
>
>


--------------000801030606030008010207
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit




content="text/html;charset=ISO-8859-15">



My meaning is how can I get all the fields name of a table?



ID  Name  Age ....

1  John   20

2 Smith  23

......



Get ID, Name and Age and so on.











wrote:

cite="mid20020902194412.GA657@fraxinus.reticulum">
Zhidian Du schrieb:



How can I get metadate of a table in PHP3?



If you think about things like the output of "\d tablename", turn on
the logging of queries, do a "\d tablename" and watch the
logfiles.

Somewhere I need the fieldtypes of a table named $this->table, the
query is

$q = "SELECT a.attname, format_type(a.atttypid, a.atttypmod)
FROM pg_class c, pg_attribute a
WHERE c.relname = '".$this->table."'
AND a.attnum > 0 AND a.attrelid = c.oid
ORDER BY a.attnum";

which is stolen from the logs - I'll never understand it ;)

Greetings,
Knut Sübert

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?











--------------000801030606030008010207--