pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
How can I get metadate of a table in PHP3?
4+ messages / 3 participants
[nested] [flat]

* How can I get metadate of a table in PHP3?
@ 2002-09-01 06:09 Zhidian Du <zdu@cs.nmsu.edu>
  2002-09-02 19:44 ` Re: How can I get metadate of a table in PHP3? knut.suebert@web.de
  2002-09-03 17:04 ` Re: How can I get metadate of a table in PHP3? scott.marlowe <scott.marlowe@ihs.com>
  0 siblings, 2 replies; 4+ messages in thread

From: Zhidian Du @ 2002-09-01 06:09 UTC (permalink / raw)
  To: pgsql-php

Hi:

How can I get metadate of a table in PHP3?


Thanks.


Zhidian Du



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: How can I get metadate of a table in PHP3?
  2002-09-01 06:09 How can I get metadate of a table in PHP3? Zhidian Du <zdu@cs.nmsu.edu>
@ 2002-09-02 19:44 ` knut.suebert@web.de
  2002-09-01 22:22   ` Re: How can I get metadate of a table in PHP3? Zhidian Du <zdu@cs.nmsu.edu>
  1 sibling, 1 reply; 4+ messages in thread

From: knut.suebert@web.de @ 2002-09-02 19:44 UTC (permalink / raw)
  To: pgsql-php

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



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: How can I get metadate of a table in PHP3?
  2002-09-01 06:09 How can I get metadate of a table in PHP3? Zhidian Du <zdu@cs.nmsu.edu>
  2002-09-02 19:44 ` Re: How can I get metadate of a table in PHP3? knut.suebert@web.de
@ 2002-09-01 22:22   ` Zhidian Du <zdu@cs.nmsu.edu>
  0 siblings, 0 replies; 4+ messages in thread

From: Zhidian Du @ 2002-09-01 22:22 UTC (permalink / raw)
  To: knut.suebert@web.de; +Cc: pgsql-php

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
>
>
>  
>

^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: How can I get metadate of a table in PHP3?
  2002-09-01 06:09 How can I get metadate of a table in PHP3? Zhidian Du <zdu@cs.nmsu.edu>
@ 2002-09-03 17:04 ` scott.marlowe <scott.marlowe@ihs.com>
  1 sibling, 0 replies; 4+ messages in thread

From: scott.marlowe @ 2002-09-03 17:04 UTC (permalink / raw)
  To: Zhidian Du <zdu@cs.nmsu.edu>; +Cc: pgsql-php

On Sun, 1 Sep 2002, Zhidian Du wrote:

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

I haven't driven PHP V3 since V4 came out, so I'm not sure if these are 
supported, but try these commands:

pg_field_name()
pg_field_type()

You can do a "select * from table limit 1" to get a sample row.  Then use 
pg_num_rows() to find out how many rows you have and iterate the name and 
type functions over each field to find out.




^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2002-09-03 17:04 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-09-01 06:09 How can I get metadate of a table in PHP3? Zhidian Du <zdu@cs.nmsu.edu>
2002-09-02 19:44 ` knut.suebert@web.de
2002-09-01 22:22   ` Zhidian Du <zdu@cs.nmsu.edu>
2002-09-03 17:04 ` scott.marlowe <scott.marlowe@ihs.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox