Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Re^3: Why did DBIC overtake CDBI?

by siracusa (Friar)
on Sep 13, 2006 at 02:50 UTC ( #572649=note: print w/ replies, xml ) Need Help??

in reply to Re^2: Why did DBIC overtake CDBI?
in thread Why did DBIC overtake CDBI?

aside: one thing that bugs me about the various ORM solutions is that they want to handle their own db connections and want me to provide DSNs instead of $dbhs. with CDBI this is relatively easy to get around by overriding My::CDBI->db_Main(). is it that easy with RDBO or DBIC?

In Rose::DB::Object, the database connection is abstracted by a separate class (Rose::DB). Each RDBO object "has a" Rose::DB object, and each Rose::DB "has a" plain old DBI $dbh. If you want to get your $dbh from elsewhere and use it with RDBO, all you need to do is override init_db() in your common RDBO base class to get your $dbh, shove it into a Rose::DB object, and return it.

The database connection is "object data" in the world of RDBO and can be passed in (or swapped out) just like any other piece of data, on a per-object basis if needed. You can even load an object from one database and save it into another by swapping db objects between load() and save() operations.

(Thanks to some semi-heroic column type abstraction, you can even do this if the database software is different in the two databases (e.g., load from MySQL and save into Postgres). There's an example of this in the tutorial.)

Comment on Re^3: Why did DBIC overtake CDBI?
custom $dbh with Rose::DB?
by mreece (Friar) on Nov 05, 2006 at 02:14 UTC
    i'm commenting a bit late, so maybe i won't get an answer, but how does one "shove [an existing $dbh] into a Rose::DB object"?

    i've been reading the docs and tutorial for Rose::DB but don't see how to stuff a $dbh into it, only how to get one out.

        Right. Just make sure that the driver() of the $db is the same as the driver of the $dbh (i.e., don't try to put a Postgres $dbh into a Rose::DB object whose driver is "mysql")

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://572649]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (8)
As of 2014-09-02 07:17 GMT
Find Nodes?
    Voting Booth?

    My favorite cookbook is:

    Results (20 votes), past polls