本文整理汇总了PHP中ZurmoRedBean::setup方法的典型用法代码示例。如果您正苦于以下问题:PHP ZurmoRedBean::setup方法的具体用法?PHP ZurmoRedBean::setup怎么用?PHP ZurmoRedBean::setup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ZurmoRedBean
的用法示例。
在下文中一共展示了ZurmoRedBean::setup方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setup
/**
* Sets up the database connection.
* @param $dsn The datasource name. See: <a href="http://nl3.php.net/manual/en/pdo.construct.php">http://nl3.php.net/manual/en/pdo.construct.php</a>
* @code
* "sqlite:database.txt"
* "mysql:host=localhost;dbname=oodb"
* "pgsql:host=localhost;dbname=oodb"
* @endcode
* @param $username The database user's login username.
* @param $password The database user's login password.
*/
public static function setup($dsn, $username, $password)
{
assert('is_string($dsn) && $dsn != ""');
assert('$username == null || is_string($username) && $username != ""');
assert('$password == null || is_string($password)');
assert('!self::isSetup()');
try {
ZurmoRedBean::setup($dsn, $username, $password);
static::freeze();
if (SHOW_QUERY_DATA) {
Yii::app()->performance->setRedBeanQueryLogger(ZurmoRedBeanPluginQueryLogger::getInstanceAndAttach(ZurmoRedBean::$adapter));
}
if (defined('REDBEAN_DEBUG_TO_FILE') && REDBEAN_DEBUG_TO_FILE) {
$queryLoggerComponent = Yii::createComponent(array('class' => 'application.core.models.ZurmoRedBeanQueryFileLogger'));
$queryLoggerComponent->init();
Yii::app()->setComponent('queryFileLogger', $queryLoggerComponent);
ZurmoRedBean::debug(true, Yii::app()->queryFileLogger);
} else {
ZurmoRedBean::debug(defined('REDBEAN_DEBUG') && REDBEAN_DEBUG);
}
self::$isSetup = true;
self::$databaseType = substr($dsn, 0, strpos($dsn, ':'));
} catch (Exception $e) {
self::close();
throw $e;
}
assert('static::isSetup()');
assert('RedBeanDatabase::isFrozen()');
}