Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 2C720476426 for ; Mon, 2 Sep 2002 18:23:31 -0400 (EDT) Received: from bubba.NMSU.Edu (bubba.NMSU.Edu [128.123.3.39]) by postgresql.org (Postfix) with ESMTP id 5655F47641B for ; Mon, 2 Sep 2002 18:23:28 -0400 (EDT) Received: from dns1.nmsu.edu (dns1.NMSU.Edu [128.123.3.5]) by bubba.NMSU.Edu (8.10.2+Sun/8.9.0) with ESMTP id g82MNGR05641; Mon, 2 Sep 2002 16:23:17 -0600 (MDT) Received: from nestor.NMSU.Edu (nestor.NMSU.Edu [128.123.34.146]) by dns1.nmsu.edu (8.9.3/8.9.0) with ESMTP id QAA16134; Mon, 2 Sep 2002 16:23:18 -0600 (MDT) Received: from cs.nmsu.edu ([128.123.37.101]) by nestor.NMSU.Edu (AIX4.3/8.9.3/8.9.0) with ESMTP id QAA119646; Mon, 2 Sep 2002 16:23:29 -0600 Message-ID: <3D72931B.9040902@cs.nmsu.edu> Date: Sun, 01 Sep 2002 16:22:19 -0600 From: Zhidian Du User-Agent: Mozilla/5.0 (Windows; U; Win 9x 4.90; en-US; rv:1.0rc2) Gecko/20020618 Netscape/7.0b1 X-Accept-Language: en-us, en MIME-Version: 1.0 To: knut.suebert@web.de Cc: "pgsql-php@postgresql.org" Subject: Re: How can I get metadate of a table in PHP3? References: <3D71AF16.E4216C05@cs.nmsu.edu> <20020902194412.GA657@fraxinus.reticulum> Content-Type: multipart/alternative; boundary="------------000801030606030008010207" X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200209/7 X-Sequence-Number: 1462 --------------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 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--