You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Michael G Schwern <sc...@pobox.com> on 2002/07/16 23:39:05 UTC

DBI->connect_cached not playing with Apache::DBI

An Ima::DBI user recently pointed out that DBI->connect_cached is not using
Apache::DBI like DBI->connect does and DBI->connect_cached has slightly
different semantics from Apache::DBI.

    sub connect_cached {
        # XXX we expect Apache::DBI users to still call connect()
        my ($class, $dsn, $user, $pass, $attr) = @_;
        ($attr ||= {})->{dbi_connect_method} = 'connect_cached';
        return $class->connect($dsn, $user, $pass, $attr);
    }

There's a problem with the logic in the comment above.  Apache::DBI is
supposed to be transparently used by DBI.  So, in effect, there are no
Apache::DBI users.  More pragmatically, I write a lot of dual-natured
programs.  Stuff that might be run under Apache::Registry or might be
a stand-alone.  I like using connect_cached() because I don't have to
store a global $Dbh, but I thought I was getting the performance boosts of
Apache::DBI where applicable.

So I guess the question is, why doesn't DBI->connect_cached just defer to
Apache::DBI->connect?


-- 
This sig file temporarily out of order.