本文整理汇总了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;
}