Re: Getting columns in DB order
        
        
        [prev]
        [thread]
        [next]
        
        [Date index for 2005/06/14]
        
        
        
        
        Sam Tregar wrote:
>On Tue, 14 Jun 2005, Randal L. Schwartz wrote:
>
>  
>
>>Sam> Do you carry that philosophy into your UI as well?  This CSV data will
>>Sam> end up in Excel for analysis outside my app.  Do you really think
>>Sam> column order doesn't matter there?
>>
>>The order of the columns in the *database* shouldn't matter.  Yes, you
>>should have some sort of out-of-band description about the particular
>>columns your reports will have.  That's not the job of the database.
>>The job of the database is to give you the data.  The job of your
>>report is to format that in a manner necessary for the next step.
>>    
>>
>
>Yeah, I can dig it.  I was hoping to avoid putting the same
>information (the list of fields in the "person" table) in two places.
>It's already in person.sql and now it has to be in Person.pm too.  If
>I remove a field from one I'll have to remember to update the other.
>Suck.
>  
>
Seems to me that if the information exists, it's nice to be able to use it:
# Get deep into CDBI to extract the columns in the same order as defined 
in the database.
# In fact, this returns the columns in the order they were originally 
supplied to
# $proto->columns( All => [ col list ] ) Defaults
# to the order returned from the database query in CDBI::Loader, which 
for MySQL,
# is the same as the order in the database.
sub db_order_columns
{
    my ( $proto ) = @_;
   
    return @{ $proto->__grouper->{_groups}->{All} };
}
d.
        
     
    
    
        
  | 
 
	 (message missing) 
 |