Re: how to find out column types?

[prev] [thread] [next] [Date index for 2004/12/22]

From: Peter Speltz
Subject: Re: how to find out column types?
Date: 08:05 on 22 Dec 2004
--- Ted Zlatanov <tzz@xxxxxxxx.xxx> wrote:

> On Tue, 21 Dec 2004, tony-cdbitalk@xxxxx.xxx wrote:
> 
> On Tue, Dec 21, 2004 at 01:54:34PM -0500, Ted Zlatanov wrote:
> >> Given an object that subclasses Class::DBI, how can I find out the
> >> type of each column in that object?
> > 
> > What do you mean by 'type'?
> 
> Whatever the database backend means :) For MySQL this could be INT(12)
> with whether is is NULLable, for example.  I know DBI has methods for
> this, but Class::DBI::Column could provide a nice interface to them.
> The raw DBI methods are complex and need a db handle, and I was hoping
> to avoid them.
> 
> Based on Charles Bailley's answer I assume others have needed this as
> well.
> 

if your using mysql, Class::DBI::mysql has a private method   _column_info
which returns a usable hashref OF 'DESCRIBE __TABLE__' data. maybe other CDBi
drivers have it.  it returns something like : 
          {
                  'repair_id' => {
                           'extra' => 'auto_increment',
                           'default' => undef,
                           'type' => 'mediumint(8) unsigned',
                           'key' => 'PRI',
                           'null' => '',
                           'field' => 'repair_id'
                   },
                   . . .

           }

=====
pjs


		
__________________________________ 
Do you Yahoo!? 
Yahoo! Mail - now with 250MB free storage. Learn more.
http://info.mail.yahoo.com/mail_250

(message missing)

how to find out column types?
Ted Zlatanov 18:54 on 21 Dec 2004

Re: how to find out column types?
Tony Bowden 18:58 on 21 Dec 2004

Re: how to find out column types?
Ted Zlatanov 19:28 on 21 Dec 2004

Re: how to find out column types?
Peter Speltz 08:05 on 22 Dec 2004

Re: how to find out column types?
Tony Bowden 08:58 on 22 Dec 2004

Re: how to find out column types?
Ted Zlatanov 15:34 on 22 Dec 2004

Re: how to find out column types?
Tony Bowden 17:04 on 22 Dec 2004

Re: how to find out column types?
Ted Zlatanov 17:11 on 22 Dec 2004

Re: how to find out column types?
Tony Bowden 01:08 on 23 Dec 2004

Re: how to find out column types?
Stephen Quinney 07:51 on 23 Dec 2004

Re: how to find out column types?
Simon Flack 13:17 on 23 Dec 2004

Re: how to find out column types?
Ted Zlatanov 16:05 on 23 Dec 2004

Re: how to find out column types?
Peter Speltz 07:55 on 24 Dec 2004

Re: how to find out column types?
Ted Zlatanov 19:38 on 28 Dec 2004

Re: how to find out column types?
Simon Flack 21:29 on 28 Dec 2004

Re: how to find out column types?
Tony Bowden 03:55 on 29 Dec 2004

Re: how to find out column types?
Stephen Quinney 12:02 on 29 Dec 2004

Generated at 12:15 on 16 Jan 2005 by mariachi v0.52