本文整理汇总了PHP中OA_DB::changeDatabase方法的典型用法代码示例。如果您正苦于以下问题:PHP OA_DB::changeDatabase方法的具体用法?PHP OA_DB::changeDatabase怎么用?PHP OA_DB::changeDatabase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OA_DB
的用法示例。
在下文中一共展示了OA_DB::changeDatabase方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _createDatabase
/**
* create the empty database
*
* @return boolean
*/
function _createDatabase($aDsn = '')
{
if ($aDsn) {
$this->aDsn = $aDsn;
}
$GLOBALS['_MAX']['CONF']['database'] = $this->aDsn['database'];
$GLOBALS['_MAX']['CONF']['table']['prefix'] = $this->aDsn['table']['prefix'];
$GLOBALS['_MAX']['CONF']['table']['type'] = $this->aDsn['table']['type'];
// Try connecting to the database
$this->oDbh =& OA_DB::singleton(OA_DB::getDsn($this->aDsn));
if (PEAR::isError($this->oDbh)) {
$GLOBALS['_OA']['CONNECTIONS'] = array();
$GLOBALS['_MDB2_databases'] = array();
if (PEAR::isError($result)) {
$this->oLogger->logError($result->getMessage());
$this->oLogger->logErrorUnlessEmpty($result->getUserInfo());
return false;
}
//attempt to create DB
$result = OA_DB::createDatabase($this->aDsn['database']['name']);
if (PEAR::isError($result)) {
$this->oLogger->logError($result->getMessage());
$this->oLogger->logErrorUnlessEmpty($result->getUserInfo());
return false;
}
$this->oDbh = OA_DB::changeDatabase($this->aDsn['database']['name']);
if (PEAR::isError($this->oDbh)) {
$this->oLogger->logError($this->oDbh->getMessage());
$this->oLogger->logErrorUnlessEmpty($this->getUserInfo());
$this->oDbh = null;
return false;
}
$this->oLogger->log('Database created ' . $this->aDsn['database']['name']);
$this->can_drop_database = true;
}
$result = OA_DB::createFunctions();
if (PEAR::isError($result)) {
$this->oLogger->logError($result->getMessage());
return false;
}
return true;
}