[Catalyst] How to use CDBI model outside Catalyst
apv
apv at sedition.com
Tue Dec 6 09:00:09 CET 2005
I just ran into this yesterday. I think you need to call your base app
class to do the initializations and get the tables and classes loaded.
use MyApp;
And then the "MyApp::NAMESPACE::Table->whatever()" will work.
I would actually prefer it if the CDBI class would do its own
initialization
if that's an idea that makes design sense.
-Ashley
On Monday, December 5, 2005, at 11:41 PM, Maxim Nechaev wrote:
> I have a Catalyst Application with CDBI model:
>
> ## MyApp/lib/MyApp/Model/CDBI.pm #################
> package MyApp::Model::CDBI;
> use base 'Catalyst::Model::CDBI';
> use strict;
> use warnings;
>
> __PACKAGE__->config
> (
> 'Class-DBI' =>
> {
> dsn => 'dbi:mysql:test',
> user => 'root',
> password => '',
> options => {},
> relationships => 0,
> },
> );
>
> 1;
> ##################################################
>
>
>
> Also I have a script outside Catalyst application in which i want use
> CDBI model. Now this script look like:
>
> ## MyApp/script/myapp_cron.pl ####################
> #!/usr/bin/perl -w
>
> use strict;
> use FindBin;
> use lib "$FindBin::Bin/../lib";
>
> use MyApp::Model::CDBI;
> ...
> ##################################################
>
> But it is not enough to start using MyApp::Model::CDBI::* classes.
> I think there need some additional initialization. But i can't find
> which.
> Can anybody help me?
> Thanks.
>
>
> --
> Maxim Nechaev
>
>
> _______________________________________________
> Catalyst mailing list
> Catalyst at lists.rawmode.org
> http://lists.rawmode.org/mailman/listinfo/catalyst
>
>
More information about the Catalyst
mailing list