[Catalyst] Reading Database At Startup
Matthias Dietrich
mdietrich at cpan.org
Sun Aug 16 15:52:06 GMT 2009
Ovid,
Am 16.08.2009 um 17:09 schrieb Ovid:
> Hi all,
>
> This should be painfully obvious, but I don't see it :)
>
> 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:
>
> 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;
>
>
> But the country list is static and I want this available at
> startup. 'sub begin' fails because that's called once per request,
> not once per app.
>
> What's the recommend way of handling this? (I'm using DBIx::Class
> for the model)
I've done something similar with C::P::I18N::DBI (see: http://search.cpan.org/perldoc?Catalyst::Plugin::I18N::DBI
) but I think it wouldn't be recommended to build a plugin in your
case.
matt
--
rainboxx Matthias Dietrich
Freier Software Engineer
rainboxx | Tel.: +49 (0) 151 / 50 60 78 64
Tölzer Str. 19 | Mail: matt at rainboxx.de
70372 Stuttgart | WWW : http://www.rainboxx.de
XING: https://www.xing.com/profile/Matthias_Dietrich18
GULP: http://www.gulp.de/profil/rainboxx.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 194 bytes
Desc: Signierter Teil der Nachricht
Url : http://lists.scsys.co.uk/pipermail/catalyst/attachments/20090816/ceac2403/PGP.pgp
More information about the Catalyst
mailing list