本文整理汇总了PHP中RedBeanPHP\Facade::selectDatabase方法的典型用法代码示例。如果您正苦于以下问题:PHP Facade::selectDatabase方法的具体用法?PHP Facade::selectDatabase怎么用?PHP Facade::selectDatabase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RedBeanPHP\Facade
的用法示例。
在下文中一共展示了Facade::selectDatabase方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testInvalidDB
/**
* Github issue #458, selectDatabase causes PHP notice undefined index
* if database key not found.
*
* @return void
*/
public function testInvalidDB()
{
try {
R::selectDatabase('idontexist');
fail();
} catch (RedException $exception) {
pass();
}
}
示例2: testTransactionInFacade
//.........这里部分代码省略.........
fail();
} catch (\Exception $e) {
pass();
}
testpack('Test Camelcase 2 underscore');
$names = array('oneACLRoute' => 'one_acl_route', 'ALLUPPERCASE' => 'alluppercase', 'clientServerArchitecture' => 'client_server_architecture', 'camelCase' => 'camel_case', 'peer2peer' => 'peer2peer', 'fromUs4You' => 'from_us4_you', 'lowercase' => 'lowercase', 'a1A2b' => 'a1a2b');
$bean = R::dispense('bean');
foreach ($names as $name => $becomes) {
$bean->{$name} = 1;
asrt(isset($bean->{$becomes}), TRUE);
}
testpack('Misc Tests');
R::debug(1);
flush();
ob_start();
R::exec('SELECT 123');
$out = ob_get_contents();
ob_end_clean();
flush();
pass();
asrt(strpos($out, 'SELECT 123') !== FALSE, TRUE);
R::debug(0);
flush();
ob_start();
R::exec('SELECT 123');
$out = ob_get_contents();
ob_end_clean();
flush();
pass();
asrt($out, '');
R::debug(0);
pass();
testpack('test to string override');
$band = R::dispense('band');
$str = strval($band);
asrt($str, 'bigband');
testpack('test whether we can use isset/set in model');
$band->setProperty('property1', 123);
asrt($band->property1, 123);
asrt($band->checkProperty('property1'), TRUE);
asrt($band->checkProperty('property2'), FALSE);
$band = new \Model_Band();
$bean = R::dispense('band');
$bean->property3 = 123;
$band->loadBean($bean);
$bean->property4 = 345;
$band->setProperty('property1', 123);
asrt($band->property1, 123);
asrt($band->checkProperty('property1'), TRUE);
asrt($band->checkProperty('property2'), FALSE);
asrt($band->property3, 123);
asrt($band->property4, 345);
testpack('Can we pass a\\PDO object to Setup?');
$pdo = new \PDO('sqlite:test.db');
R::addDatabase('pdo', $pdo);
R::selectDatabase('pdo');
R::getCell('SELECT 123;');
testpack('Test array interface of beans');
$bean = R::dispense('bean');
$bean->hello = 'hi';
$bean->world = 'planet';
asrt($bean['hello'], 'hi');
asrt(isset($bean['hello']), TRUE);
asrt(isset($bean['bye']), FALSE);
$bean['world'] = 'sphere';
asrt($bean->world, 'sphere');
foreach ($bean as $key => $el) {
if ($el == 'sphere' || $el == 'hi' || $el == 0) {
pass();
} else {
fail();
}
if ($key == 'hello' || $key == 'world' || $key == 'id') {
pass();
} else {
fail();
}
}
asrt(count($bean), 3);
unset($bean['hello']);
asrt(count($bean), 2);
asrt(count(R::dispense('countable')), 1);
// Otherwise untestable...
$bean->setBeanHelper(new SimpleFacadeBeanHelper());
R::getRedBean()->setBeanHelper(new SimpleFacadeBeanHelper());
pass();
// Test whether properties like owner and shareditem are still possible
testpack('Test Bean Interface for Lists');
$bean = R::dispense('bean');
// Must not be list, because first char after own is lowercase
asrt(is_array($bean->owner), FALSE);
// Must not be list, because first char after shared is lowercase
asrt(is_array($bean->shareditem), FALSE);
asrt(is_array($bean->own), FALSE);
asrt(is_array($bean->shared), FALSE);
asrt(is_array($bean->own_item), FALSE);
asrt(is_array($bean->shared_item), FALSE);
asrt(is_array($bean->{'own item'}), FALSE);
asrt(is_array($bean->{'shared Item'}), FALSE);
}