/** * (Low level) Get the db connection for a class * @param string $class the class name * @param epClassMap $cm the class map * @return false|epDb */ protected function &_getDb($cm) { // get class name $class = $cm->getName(); // check if db conx for the class has been cached if (isset($this->dbs[$class])) { return $this->dbs[$class]; } // get dsn from class map $dsn = $cm->getDsn(); if (!$dsn) { throw new epExceptionManagerBase('Cannot find DSN for class [' . $class . ']'); return self::$false; } // have we initialized db factory yet? if (!$this->dbf) { $this->initialize(true); } // get the db connection from db factory $db = $this->dbf->make($dsn); if (!$db) { throw new epExceptionManagerBase('Cannot establish database connection for class [' . $class . ']'); return self::$false; } // set check_table_exists options to db $db->setCheckTableExists($this->getConfigOption('check_table_exists')); // check if in transition. if so add db to watch if ($this->t) { $this->t->addDb($db); } // log queries if set $db->logQueries($this->getConfigOption('log_queries')); // create table if not exist if (!$db->create($cm)) { throw new epExceptionManagerBase('Cannot create table for class [' . $class . ']'); return self::$false; } // cache db for class return $this->dbs[$class] =& $db; }