[Catalyst] getting the db connection used by catalyst
Brandon Black
blblack at gmail.com
Wed Oct 4 01:48:53 CEST 2006
On 10/3/06, Daniel McBrearty <danielmcbrearty at gmail.com> wrote:
>
> if you have a (dbix) database, and use it as a model, you generally
> end up doing this :
>
> $c->model-> ....
>
> and the database connection is handled internally.
>
> I now want to write another model which uses the db. It would be
> better to use the existing connection that cat has created, rather
> than create another one.
>
> If I write a new() method for this model, does it have access to the
> context? what is a good way to do this?
What kind of model is your new model, and how will it use/store/whatever the
$dbh? There are a lot of ways to do what you're talking about in general,
it all depends on what's right for your design. Be aware that once you take
the raw $dbh from DBIC and start using it yourself, you lose all of its
fancy connection management.
-- Brandon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.rawmode.org/pipermail/catalyst/attachments/20061003/c89a18ba/attachment.htm
More information about the Catalyst
mailing list