Re: Get a list of column field names from a MS Access table

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, 2009-02-28 at 00:40 -0500, Andrew Ballard wrote:
> On Fri, Feb 27, 2009 at 7:41 PM, Ashley Sheridan
> <ash@xxxxxxxxxxxxxxxxxxxx> wrote:
> > On Fri, 2009-02-27 at 16:58 -0500, Bastien Koert wrote:
> >> On Thu, Feb 26, 2009 at 4:01 PM, revDAVE <Cool@xxxxxxxxxxxxxxxx> wrote:
> >>
> >> > Newbie question:
> >> >
> >> > I would like to get a list of column field names from a MS Access table and
> >> > hopefully get them returned in the ORIGINAL order (as they appear in
> >> > access)
> >> >
> >> > Is there a sql query I could do to get this result?
> >> >
> >> >
> >> >
> >> >
> >> > --
> >> > Thanks - RevDave
> >> > Cool @ hosting4days . com
> >> > [db-lists 09]
> >> >
> >> >
> >> >
> >> >
> >> > --
> >> > PHP General Mailing List (http://www.php.net/)
> >> > To unsubscribe, visit: http://www.php.net/unsub.php
> >> >
> >> >
> >> A dirty way is to query the table where 1=2 to return no results
> >>
> >> select * from table where 1=2
> >>
> > That'll just return an empty result set, as in empty and with no fields
> > output! In MySQL you can do this:
> >
> > SELECT column_name FROM information_schema.columns WHERE table_name =
> > 'table_name'
> >
> > this might help with doing the same for M$Access?
> >
> >
> > Ash
> > www.ashleysheridan.co.uk
> >
> 
> I haven't ever seen information_schema in M$ Access.
> 
> Andrew
> 
I guess then you could do something like this:

$row_names = Array();
$query = "SELECT TOP 1 * FROM table_name";
$result = mssql_query($query);
while($row = mssql_fetch_array($result))
{
    foreach($row as $key => $value)
    {
        $row_names[] = $key;
    }
}

I know it's a little messy there with the double loop, and I'm sure we
can get rid of the while, but I've just woken up, so I'm not too compos
mentis just yet!


Ash
www.ashleysheridan.co.uk


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux