[Dbix-class] DBIx::Class and mod_perl

Brandon Black blblack at gmail.com
Wed Mar 22 18:08:59 CET 2006


On 3/22/06, Rolf Schaufelberger <rs at plusw.de> wrote:
> Hi,
>
> I'm currently using Class::DBI in some larger web applications and "watching"
> this list. I've been playing around a bit with it (0.0499) and now have two
> questions:
>

0.04999_xx are an old development series now, you should probably be
playing with either 0.0500x stable series or the 0.05999_xx dev
series.

> What is the preferred way to have DBIx::Class to run with mod_perl ?
> With CDBI I use the solution described here:
> http://wiki.class-dbi.com/wiki/Using_with_mod_perl
>

Generally speaking, you use DBIx::Class under mod_perl just like you
would use it when you're not under mod_perl.  It should handle
everything fine without any special treatment.

> Question 2 is: I'm using Postgres and my database is spread over different
> schemas. So, i set the search_path in my Db_Main with values set by
> parameters (that are VirtualHost dependend ). Now I haven't found any way
> where I can place some code to execute directly after the connection.
> Since this code sets session parameters I need to do this only once after
> connecting and then cache my dbh in $r->pnotes (as described above).
>
> What would be the recommended way to do this in DBIX::Class ?

DBIx::Class::Storage::DBI supports "on_connect_do" to execute a series
of SQL statements just after making any connection to the database
(and will replay them if it needs to reconnect for whatever reason,
etc).

$schema->storage->on_connect_do([ 'some sql statement', 'another sql
statement' ]);

-- Brandon



More information about the Dbix-class mailing list