[CDBI] "commit ineffective" and CDBI::Loader

Bill Moseley moseley at hank.org
Fri Oct 28 04:22:52 BST 2005

The summary of the problem is CDBI::Loader is creating a db_Main for
every class instead of the more common db_Main in a base class.

This results in connect_cached() being called the first time each
class is accessed.  If this happens during a transaction then DBI's
AutoCommit can get turned back on -- and that causes the "commit
ineffective" message.

I'm not clear what happens in DBI -- seems like the commit still
happens.  Maybe that's DBD-specific, though.  I didn't look at that.

What's the best solution?  One option would be for Loader to create
db_Main in its super class -- but that breaks if more than one
connection is used.  Another option is for Loader to generate a unique
class and make all loaded classes inherit from that class.  But, that
doesn't work if some classes are not not created with Loader.

Really, what should happen is loader should be passed a base class and
use that.  That way classes that are not loaded by CDBI::Loader will
use the same db_Main method as the loaded classes.

Although there's "left_base_classes" and "additional_base_classes"
they are both arrays.  Should there be a "base_class" option?  And
what to do when there is no base class provided?

Again, this only happens the first time a class is accessed -- and
when in a transaction -- so it's not much of a problem it seems.

Maybe the solution is to stay away from Loader. ;)

Bill Moseley
moseley at hank.org

More information about the ClassDBI mailing list