Re: Mixed Case Column Names
[prev]
[thread]
[next]
[Date index for 2005/04/14]
my @columns = map { $_->name } TPG_Staging->columns;
Gives you the column name
On Thursday 14 April 2005 16:26, Jay Hargreaves wrote:
> Hi everyone!
>
> I have the following table module:
>
> --- TPG_Staging.pm ---
> package TPG_Staging;
> use base TPG_DBI;
>
> __PACKAGE__->table("Staging");
> __PACKAGE__->columns(Primary => qw(ClientID));
> __PACKAGE__->columns(Others => qw(JobReference SSC PostcodeArea Format
> LT_60g Machinable BagWeight BagItems Sortation AccessSiteCode
> AccessPoint BagID CollectionDate HandoverDate ServiceRegister
> MailingHouseID));
> ---
>
> When I query the columns that are contained in the table:
>
> my @columns = TPG_Staging->columns;
>
> I receive a list of the columns as expected but with all the the names
> in lower case. It is important that the column names are presented AS IS
> since they are used directly in my user interface.
>
> Is this lower-casing always the case with Class::DBI? I have not
> experienced this problem before as I tend to use lower-case column names
> as standard. Is there a way around this problem other than providing
> explicit mappings from the lower-case name to the uppercase name:
>
> ---
> # accessor is simple enough
> sub accessor_name
> { my ($class, $column) = @_;
> return lc $column;
> }
>
> # mutator requires explicit mapping
> sub mutator_name
> { my ($class, $column) = @_;
> my %mutator = ( clientid => 'ClientID',
> jobreference => 'JobReference',
> ...
> );
> return $mutator($column);
> }
> ---
>
> I am using Class::DBI 0.96 on Windows XP with MySQL ver 4.0.15.
>
> Thanks
> Jay
--
Met vriendelijke groet,
itXL
Daniel Wijnands
daniel@xxxx.xx
|
|
Re: Mixed Case Column Names
Daniel Wijnands 14:51 on 14 Apr 2005
|