Re: pear DB and column names
| From: | Justin Patrin | Date: | Wed, 18 May 2005 16:48:41 +0000 |
| Subject: | Re: pear DB and column names | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-19262@lists.php.net to get a copy of this message | ||
On 5/18/05, Anoop Bhat <abhat@interpublic.com> wrote:
> Is there any way to get the column names from a query?
>
> like mysql_field_name.
>
> The db i'm using is infact mysql but i haven't seen a function where i
> can get the column names from the result of a query.
>
> is there some way to get the column names with pear DB?
>
Well, you can use tableInfo() on the statement handle. *or* you can
use DB_FETCHMODE_ASSOC.
$sth = $db->query($sql);
while ($rec = $sth->fetchRow(DB_FETCHMODE_ASSOC)) {
print_r($rec);
}
print_r($sth->tableInfo());
--
Justin Patrin