Camping and DBI
Eric Mill
kprojection at gmail.com
Fri Jan 26 23:28:27 EST 2007
Maybe, but does that benefit you? Constants aren't allowed to be set
more than once (when you first define them), so using one as a DB
connection might potentially cause problems if you ever reset it.
It's also "unfashionable" in Ruby land to use constants over instance
variables for this work.
-- Eric
On 1/26/07, James <jamesd.earl at gmail.com> wrote:
> On 1/26/07, Lennon Day-Reynolds <rcoder at gmail.com> wrote:
> > That way, your connection will only be established once per model
> > class, and will stay open between requests. Alternately, you could set
> > @@dbh instead of @dbh, which would open just one connection for all
> > your model classes, but you might have problems handling multiple
> > simultaneous requests through a single active database handle.
>
> Thanks, I learned something new! Would it be okay to use a constant
> DBH to represent the database handle?
>
> James
> _______________________________________________
> Camping-list mailing list
> Camping-list at rubyforge.org
> http://rubyforge.org/mailman/listinfo/camping-list
>
More information about the Camping-list
mailing list