On 5/22/06 7:07 PM, Jonathan Vanasco wrote:
> On May 22, 2006, at 5:34 PM, John Siracusa wrote:
>> Manager methods take a db parameter, If one is not passed, then one
>> will be created by calling the init_db() method of the object class.
>> So, you should be able to pass in a pre-injected-with-your-desired-dbh
>> Rose::DB-derived object as the db parameter to your Manager call, or
>> you could override init_db() in your object class to return such a
>> thing.
>
> I didn't have a Rose::DB derived db object
Sure, but you can make one, right? You've already got the $dbh. Just make
a new Rose::DB-derived object and shove the $dbh in there :) If you do this
a lot, you can make a helper function for it:
$db = make_me_a_db_from($dbh);
or even wrap the Manager methods with custom versions that do this for you
and then call through to the real versions.
> but i tried this...and it worked in an unexpected way->
>
> my $dbh= standard DBI handle
> $loaded= Object::Manager->get_assets( query=>[params], dbh=> $dbh );
>
> it worked. i dont think it should have, but it did.
Undocumented! Beware! Although that probably does work for you, the
Manager needs a db some way or another. So while it will use your $dbh, it
will also call YourObjectClass->init_db to get a Rose::DB-derived object to
use.
Remember, Rose::DB does more than just provide the $dbh. It also
encapsulates database-specific behavior. So your naughty, undocumented
example code above relies on YourObjectClass->init_db returning a db object
whose driver is the same as your $dbh.
When you do it the documented, supported way, you're guaranteed that they'll
match because trying to inject a $dbh into a Rose::DB-derived object will
cause a fatal error if the drivers don't match.
-John
-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Rose-db-object mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rose-db-object