in reply to question on OO design and object composition

No need to pass your DBI handles around like that, just get a new one using connect_cached() and you'll automatically share a single handle.

-sam

  • Comment on Re: question on OO design and object composition

Replies are listed 'Best First'.
Re^2: question on OO design and object composition
by Qiang (Friar) on Mar 22, 2008 at 02:33 UTC
    i am aware of connect_cached. however, we use different user/pwd for every webapps so the $dbh i pass to company::api is that special dbh for a certain webapp. there is no way to get the dbh except passing it from the webapp.

    it would be much simpler if we are using a sigle dbh handler for every apps so i could do company::db->dbh to get the same dbh all the time. but that is not the case for me..

      Huh? So you want to share around a DBI handle, but you can't use connect_cached because each object has its own user/pass. If that's the case, how can you share a DBI handle in the first place?

      -sam

        i am using connect_cached().

        my problem is that i have to pass a dbh(supposedly one for each webapp under mod_perl) to the company::api by way of calling $c = company::api->new($dbh). then in company::api, i have to pass this $dbh to other company:: modules

        sorry if i wasn't clear on this.