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.)