You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Adam Gotheridge <ad...@foxvalley.net> on 2000/04/05 00:28:56 UTC

dumb beginner question

I have been using zope for a while and while it is cool, I really like the
speed/power/ease-of-use of perl so I would like to mimick some of the more
important functions I saw in zope and I can't figure it out.

One of the cool zope things was that you made one db connection object and then
all database interaction referenced that connection object. If you had to change
the connection string, it was in one place.

How can I do something like that in modperl? I am thinking I should be able to
just create a one-line connection string in a a file at the base of a site, and
then include that file in all perl pages. That takes care of the one place to
change it problem, but I am not getting it.

Something like
con.txt
my $dbh ||= DBI->connect("dbi:Oracle:host=red.home.com;sid=RED", 'scott',
'tiger') || die "Can't connect to : DBI->errstr";

and then in the cgi file say somthing like:
include(con.txt)

There must be an easy way to do this!

Thanks



Re: dumb beginner question

Posted by Jeff Beard <je...@cyberxape.com>.
http://perl.apache.org/guide/performance.html#Persistent_DB_Connections

The answers to most beginner questions are in the guide as well.

--Jeff

At 05:28 PM 4/4/00, Adam Gotheridge wrote:
>I have been using zope for a while and while it is cool, I really like the
>speed/power/ease-of-use of perl so I would like to mimick some of the more
>important functions I saw in zope and I can't figure it out.
>
>One of the cool zope things was that you made one db connection object and 
>then
>all database interaction referenced that connection object. If you had to 
>change
>the connection string, it was in one place.
>
>How can I do something like that in modperl? I am thinking I should be able to
>just create a one-line connection string in a a file at the base of a 
>site, and
>then include that file in all perl pages. That takes care of the one place to
>change it problem, but I am not getting it.
>
>Something like
>con.txt
>my $dbh ||= DBI->connect("dbi:Oracle:host=red.home.com;sid=RED", 'scott',
>'tiger') || die "Can't connect to : DBI->errstr";
>
>and then in the cgi file say somthing like:
>include(con.txt)
>
>There must be an easy way to do this!
>
>Thanks



Jeff Beard
_______________________________
Web:		www.cyberxape.com
Phone:	303.443.9339
Location:	Boulder, CO, USA