Re: Column Names

[prev] [thread] [next] [Date index for 2005/02/10]

From: Peter Speltz
Subject: Re: Column Names
Date: 20:36 on 10 Feb 2005
--- Justin Tocci <jtocci@xxxxxx.xxx> wrote:

> I ended up setting up methods to be able to access columns in the order 
> I would like and give them user presentable names.
> 
> Is there already a way to do this or did I do the right thing?
> 

As far as i know CDBI doesn't offer standard methods to do this. I think it
should as its so common.

Maypole's  base model class has methods for this:

sub column_names {
 # returns hash mapping names to human readable names 
 # acutal code: 
    my $class = shift;
    map {
        my $col = $_;
        $col =~ s/_+(\w)?/ \U$1/g;
        $_ => ucfirst $col
    } $class->columns;
}

and

sub display_columns { 
# array of columns to display on forms and in order you want them displayed 
}

Maypole also has list_columns which is columns to display when viewing an
object. It defaults to display_columns.

> package My::Xadmin;
> 
> use strict;
> use base 'My::TestDB';
> 
> __PACKAGE__->table('xadmin');
> __PACKAGE__->columns(All => qw/xuser_id full_name login_name 
> login_password email_address phone_number other_info 
> user_permissions/);
> 
> __PACKAGE__->sequence('global_seq');
> 
> sub col {
> my @col=( "Full Name", "Login Name", "Login Password", "Email Address", 
> "Phone Number", "Other Info", "User Permissions" );
> }
> 
> sub view {
> my @view=(qw/ full_name login_name login_password email_address 
> phone_number other_info user_permissions /);
> }
> 
> 1;
> 
> -------------------
> #code to print nice output:
> my @views = $class->view();
> my @cols = $class->col();
> foreach (@objf) {
> 	if (defined($_->login_name)) {
> 		foreach my $cols (@cols) {
> 			print $cols,"\t";
> 		}
> 		print "\n";
> 		foreach my $views (@views) {
> 			print $_->$views,"\t\t";
> 		}
> 		print "\n";
> 	} else {
> 		print "Empty\n";
> 	}
> }
> 
> 


=====
pjs


		
__________________________________ 
Do you Yahoo!? 
The all-new My Yahoo! - What will yours do?
http://my.yahoo.com 

(message missing)

Column Names
Justin Tocci 05:19 on 10 Feb 2005

Re: Column Names
Peter Speltz 20:36 on 10 Feb 2005

Re: Column Names
Rod McChesney 20:56 on 10 Feb 2005

CDBI and mod_perl
Rod McChesney 20:58 on 10 Feb 2005

Re: CDBI and mod_perl
Perrin Harkins 21:37 on 10 Feb 2005

Re: CDBI and mod_perl
Drew Wilson 21:54 on 10 Feb 2005

Re: CDBI and mod_perl
karjala_lists 13:59 on 15 Feb 2005

Re: CDBI and mod_perl
Perrin Harkins 22:16 on 10 Feb 2005

Re: CDBI and mod_perl
Drew Wilson 22:27 on 10 Feb 2005

Re: CDBI and mod_perl
Perrin Harkins 22:46 on 10 Feb 2005

Re: CDBI and mod_perl
Edward J. Sabol 23:42 on 10 Feb 2005

Re: CDBI and mod_perl
Rod McChesney 01:55 on 12 Feb 2005

Re: CDBI and mod_perl
Edward J. Sabol 19:43 on 12 Feb 2005

Re: CDBI and mod_perl
Rod McChesney 18:48 on 14 Feb 2005

Re: CDBI and mod_perl
Perrin Harkins 21:23 on 14 Feb 2005

Re: CDBI and mod_perl
Edward J. Sabol 06:53 on 14 Feb 2005

Re: CDBI and mod_perl
Perrin Harkins 21:14 on 14 Feb 2005

Re: CDBI and mod_perl
Perrin Harkins 19:59 on 15 Feb 2005

Re: CDBI and mod_perl
Tim Bunce 22:33 on 15 Feb 2005

Re: CDBI and mod_perl
Tony Bowden 22:12 on 18 Feb 2005

Re: CDBI and mod_perl
=?ISO-8859-1?Q?Ask_Bj=F8rn_Hansen?= 22:19 on 18 Feb 2005

Re: CDBI and mod_perl
Perrin Harkins 22:36 on 18 Feb 2005

Re: CDBI and mod_perl
Tony Bowden 11:23 on 19 Feb 2005

Re: CDBI and mod_perl
Perrin Harkins 13:56 on 19 Feb 2005

Re: CDBI and mod_perl
Tony Bowden 15:57 on 19 Feb 2005

Re: CDBI and mod_perl
Perrin Harkins 16:21 on 19 Feb 2005

Re: CDBI and mod_perl
Perrin Harkins 16:24 on 19 Feb 2005

Re: CDBI and mod_perl
Tony Bowden 09:54 on 20 Feb 2005

Re: CDBI and mod_perl
Perrin Harkins 21:31 on 20 Feb 2005

Re: CDBI and mod_perl
Tony Bowden 22:19 on 20 Feb 2005

Generated at 12:48 on 22 Feb 2005 by mariachi v0.52