本文整理汇总了PHP中OA_DB::createDatabase方法的典型用法代码示例。如果您正苦于以下问题:PHP OA_DB::createDatabase方法的具体用法?PHP OA_DB::createDatabase怎么用?PHP OA_DB::createDatabase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OA_DB
的用法示例。
在下文中一共展示了OA_DB::createDatabase方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setupDB
/**
* A method for setting up a test database.
*
* @param bool $ignore_errors True if setup errors should be ignored.
*/
static function setupDB($ignore_errors = false)
{
$oDbh =& OA_DB::singleton();
if (PEAR::isError($oDbh)) {
$aConf = $GLOBALS['_MAX']['CONF'];
$result = OA_DB::createDatabase($aConf['database']['name']);
if (PEAR::isError($result) && !$ignore_errors) {
PEAR::raiseError("TestEnv unable to create the {$aConf['database']['name']} test database." . $result->getUserInfo(), PEAR_LOG_ERR);
die(1);
}
$result = OA_DB::createFunctions();
if (PEAR::isError($result) && !$ignore_errors) {
PEAR::raiseError("TestEnv unable to create the required functions." . $result->getUserInfo(), PEAR_LOG_ERR);
die(1);
}
}
}
示例2: _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;
}