[Catalyst] Reading Database At Startup
Darren Duncan
darren at darrenduncan.net
Sun Aug 16 23:08:16 GMT 2009
Ovid wrote:
> For a personal project, I want users to be able to click on a letter and get a list of countries starting with that letter. I can do this:
Considering that there are only about 250 countries in total, you should just
list them all on one screen and be done with it.
I think that would be a lot more user friendly than requiring them to click a
letter first, especially if they're not sure exactly how their country is
spelled or what letter it might be under (eg, is "Republic of Ireland" under "I"
or "R").
Save clicking a letter when you're doing a list of cities or something.
> my $letters = $c->model('DB')->storage->dbh->selectcol_arrayref(
> 'select distinct(substr(name,1,1)) as letter from country order by letter'
> );
> $c->stash->{letters} = $letters;
Also, to use 'distinct' I don't think you ever use parens; you just say "select
distinct <foo-expr> as bar from baz ...".
-- Darren Duncan
More information about the Catalyst
mailing list