Good info, but not exactly what I'm looking for.  I'm looking for getting
the columns returned from a query, not the columns that exist in a table.
Meaning that it may contain a subset of columns, or it might contain columns
from 2 or more tables.

Thanks for your help.

-D. Israel
[EMAIL PROTECTED]
http://www.customcodebydan.com 
AIM: JudoDanIzz

A BANDAID!? Damn it Jim,I'm a doctor,not a-oh, never mind

> -----Original Message-----
> From: Jason Trebilcock [mailto:[EMAIL PROTECTED]
> Sent: Sunday, December 30, 2007 11:32 AM
> To: [email protected]
> Subject: RE: [php-list] PHP/MySQL question
> 
> 
> 
> 
> 
> From: [email protected] [mailto:[EMAIL PROTECTED] On
> Behalf
> Of James Keeline
> Sent: Sunday, December 30, 2007 12:53 PM
> To: [email protected]
> Subject: Re: [php-list] PHP/MySQL question
> 
> 
> 
> --- Daniel Israel <HYPERLINK "mailto:dan%40ebji.org"[EMAIL PROTECTED]>
> wrote:
> 
> > 1. When I do a MySQL query, is there a way to get the returned
> columns in
> > the query without fetching a row? Currently, what I'm doing is
> fetching a
> > row of data and getting the keys from the array. I'd like to do it
> without
> > fetching the row. Is this possible?
> >
> > 2. If #1 above is indeed possible, is this only possible when I get
> returned
> > rows or can I do it when there are no matching rows in the query?
> >
> > Thanks for any help!
> >
> > -D. Israel
> 
> If you have at least one row of data you could get the column names
> through
> a
> query like this:
> 
> SELECT * FROM table_name LIMIT 1;
> 
> However, in many applications this may not be practical because the
> table
> may
> be empty. You could use MySQL to describe the table for you and parse
> the
> results you want:
> 
> DESC table_name;
> 
> There are some MySQL functions in PHP which can be used for this
> purpose but
> in
> looking at the examples on HYPERLINK
> "http://php.net/mysql_fetch_field"http://php.net/mysql_fetch_field they
> seem
> more
> complex than is necessary to achieve the goal.
> 
> James
> 
> 
> 
> Or, you could run a query against information_schema.  That is,
> depending on
> the version of MySQL that you're working with (5.02 or later).
> 
> For example:
> 
> select column_name from information_schema.columns where table_name =
> 'your_table_name_here'
> 
> You might have to filter on table_schema as well if you have multiple
> schemas.
> 
> Jason
> 
> 
> No virus found in this outgoing message.
> Checked by AVG Free Edition.
> Version: 7.5.516 / Virus Database: 269.17.12/1202 - Release Date:
> 12/29/2007
> 1:27 PM
> 
> 
> 
> [Non-text portions of this message have been removed]
> 
> 
> 
> Community email addresses:
>   Post message: [email protected]
>   Subscribe:    [EMAIL PROTECTED]
>   Unsubscribe:  [EMAIL PROTECTED]
>   List owner:   [EMAIL PROTECTED]
> 
> Shortcut URL to this page:
>   http://groups.yahoo.com/group/php-list
> Yahoo! Groups Links
> 
> 
> 

Reply via email to