本文整理匯總了PHP中false::addDb方法的典型用法代碼示例。如果您正苦於以下問題:PHP false::addDb方法的具體用法?PHP false::addDb怎麽用?PHP false::addDb使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類false
的用法示例。
在下文中一共展示了false::addDb方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: epExceptionManagerBase
/**
* (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;
}