Re: order of columns from columns()

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

From: Gabriel Horner
Subject: Re: order of columns from columns()
Date: 23:56 on 12 Dec 2004
Gabriel wrote:  
> >Hi,                    
> >   I have a module that depended on the order of Class::DBI's
> >columns('All') method. I know this is a nono so I'm wondering are
> >there any modules that
> >provide a table's columns order via the same method for several
> >common databases?      
> >I'm aware of Class::DBI::$Database modules but they don't support
> >such a method. If there                                        
> >are no modules that currently do this then do the
> >Class::DBI::$Database modules seem
> >appropriate for this?

Lonely Rolling Star wrote:
> Do you need code for this? Could you just do:                                            
> our @ordered_columns = qw(id last_name first_name title salary);                                
> __PACKAGE__->columns( All => @ordered_columns );          

Gabriel wrote: 
>> I should've mentioned that I'm trying to get the columns' order while
>> using Class::DBI::Loader which means my Class::DBI subclass can only get to the columns' names
>> via columns(). Since columns() doesn't consistently return the columns in the same order
>> as they're in the database, I'm looking for what modules people use to get correct column order
>> or if perhaps Class::DBI will support this functionality.

Lonely Rolling Star wrote: 
> Ah. I see. Out of curiosity, why does the database's column order matter?
>
> I've never used this, but DBI has this function:
>        "column_info"
>              $sth = $dbh->column_info( $catalog, $schema, $table, $column );
>
> Which you may be able to use to get the column name and it's ordinal number.

Hi Aneel,

I'm rewriting a Class::DBI library for my shell framework (Fry::Shell), in other words
creating a Class::DBI-based shell. Naturally I'd want the same default column order
as one would expect in a database shell.
  I'm aware of column_info() but it's not consistently implemented
across the DBI drivers. If you look in the Class::DBI::$Database modules, there
are a couple of different ways at getting ordered columns but these modules don't
offer a common method for retrieving the columns. That's what I'm suggesting as a last resort.
I'm going to put what we've exchanged back on the list to clarify to others what I am asking.

Gabriel
        -- 
        my looovely website -- http://www.chwhat.com
BTW, IF chwhat.com goes down email me at gabriel.horner@xxxx.xx

order of columns from columns()
Gabriel Horner 20:49 on 12 Dec 2004

Re: order of columns from columns()
Gabriel Horner 23:56 on 12 Dec 2004

Generated at 09:04 on 20 Dec 2004 by mariachi v0.52