本文整理汇总了PHP中TestCaseDatabase::dbo方法的典型用法代码示例。如果您正苦于以下问题:PHP TestCaseDatabase::dbo方法的具体用法?PHP TestCaseDatabase::dbo怎么用?PHP TestCaseDatabase::dbo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TestCaseDatabase
的用法示例。
在下文中一共展示了TestCaseDatabase::dbo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUpBeforeClass
public static function setUpBeforeClass()
{
jimport('joomla.database.database');
jimport('joomla.database.table');
// First let's look to see if we have a DSN defined or in the environment variables.
if (defined('JTEST_DATABASE_MYSQLI_DSN') || getenv('JTEST_DATABASE_MYSQLI_DSN')) {
$dsn = defined('JTEST_DATABASE_MYSQLI_DSN') ? JTEST_DATABASE_MYSQLI_DSN : getenv('JTEST_DATABASE_MYSQLI_DSN');
} else {
return;
}
// First let's trim the mysql: part off the front of the DSN if it exists.
if (strpos($dsn, 'mysql:') === 0) {
$dsn = substr($dsn, 6);
}
// Split the DSN into its parts over semicolons.
$parts = explode(';', $dsn);
// Parse each part and populate the options array.
foreach ($parts as $part) {
list($k, $v) = explode('=', $part, 2);
switch ($k) {
case 'host':
self::$options['host'] = $v;
break;
case 'dbname':
self::$options['database'] = $v;
break;
case 'user':
self::$options['user'] = $v;
break;
case 'pass':
self::$options['password'] = $v;
break;
}
}
if (!is_object(self::$dbo)) {
try {
if (class_exists('JDatabaseDriver')) {
self::$dbo = JDatabaseDriver::getInstance(self::$options);
} else {
self::$dbo = JDatabase::getInstance(self::$options);
}
} catch (Exception $e) {
self::$dbo = null;
}
}
self::$database = JFactory::$database;
JFactory::$database = self::$dbo;
}