diff --git a/Doctrine/DB/LazyConnector.php b/Doctrine/DB/LazyConnector.php new file mode 100644 index 000000000..504acab5a --- /dev/null +++ b/Doctrine/DB/LazyConnector.php @@ -0,0 +1,48 @@ +. + */ +/** + * Doctrine_DB_LazyConnector + * + * @author Konsta Vesterinen + * @license LGPL + * @package Doctrine + */ +class Doctrine_DB_LazyConnector extends Doctrine_DB_EventListener { + public function onPreQuery(Doctrine_DB $dbh, array $args) { + $dbh->connect(); + } + + public function onPrePrepare(Doctrine_DB $dbh, array $args) { + $dbh->connect(); + } + + public function onPreCommit(Doctrine_DB $dbh) { + $dbh->connect(); + } + + public function onPreRollBack(Doctrine_DB $dbh) { + $dbh->connect(); + } + + public function onPreBeginTransaction(Doctrine_DB $dbh) { + $dbh->connect(); + } +}