[Catalyst] More complex Class::DBI::Sweet usage?
Danijel Milicevic
Danijel.Milicevic at rawmode.org
Fri Jul 1 12:07:32 CEST 2005
Am Freitag, den 01.07.2005, 10:36 +0100 schrieb Toby Corkindale:
> *delurk*
> In Catalyst, where is the preferred place to setup custom queries for
> autogenerated (via C::M::CDBI) classes?
> In a package named exactly the same, so you can do __PACKAGE__->set_sql(), or
> in a different package (ie. via C::M::CDBI::Foo->set_sql()) which must be
> run after the setup stage of C::M::CDBI)?
In order for Catalyst to pick up your models you should place them in
the MyApp::M:: namespace. You can do that manually for non-cdbi models
or just use the helper script and a existing database:
gabbana at spalato:~$ MyApp/script/myapp_create.pl model CDBI CDBI
dbi:SQLite:/home/gabbana/MyApp/myapp.db
created "/home/gabbana/MyApp/script/../lib/MyApp/M/CDBI"
created "/home/gabbana/MyApp/script/../lib/MyApp/M/CDBI/Cart.pm"
created "/home/gabbana/MyApp/script/../lib/MyApp/M/CDBI/Customer.pm"
created "/home/gabbana/MyApp/script/../lib/MyApp/M/CDBI/Product.pm"
...
Now just edit MyApp::M::CDBI::Cart for example and add your
__PACKAGE__->set_sql() statements.
> Cheers,
> Toby
> (Porting from Maypole)
Welcome to Catalyst. :)
Regards,
Danijel Milicevic
More information about the Catalyst
mailing list