本文整理汇总了PHP中R::adapter方法的典型用法代码示例。如果您正苦于以下问题:PHP R::adapter方法的具体用法?PHP R::adapter怎么用?PHP R::adapter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类R
的用法示例。
在下文中一共展示了R::adapter方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: close
public static function close()
{
// TODO - find out if there is a proper way.
R::$toolboxes = array();
R::$toolbox = null;
R::$redbean = null;
R::$writer = null;
R::$adapter = null;
R::$associationManager = null;
R::$extAssocManager = null;
R::$exporter = null;
R::$tagManager = null;
R::$currentDB = '';
R::$f = null;
self::$isSetup = false;
}
示例2: configureFacadeWithToolbox
public static function configureFacadeWithToolbox(RedBean_ToolBox $tb)
{
$oldTools = self::$toolbox;
self::$toolbox = $tb;
self::$writer = self::$toolbox->getWriter();
self::$adapter = self::$toolbox->getDatabaseAdapter();
self::$redbean = self::$toolbox->getRedBean();
self::$associationManager = new RedBean_AssociationManager(self::$toolbox);
self::$redbean->setAssociationManager(self::$associationManager);
self::$extAssocManager = new RedBean_ExtAssociationManager(self::$toolbox);
$helper = new RedBean_ModelHelper();
self::$redbean->addEventListener("update", $helper);
self::$redbean->addEventListener("open", $helper);
self::$redbean->addEventListener("delete", $helper);
self::$associationManager->addEventListener("delete", $helper);
self::$redbean->addEventListener("after_delete", $helper);
self::$redbean->addEventListener("after_update", $helper);
self::$redbean->addEventListener("dispense", $helper);
return $oldTools;
}
示例3: setup
/**
* Kickstarts redbean for you.
* @param string $dsn
* @param string $username
* @param string $password
*/
public static function setup($dsn = "sqlite:/tmp/red.db", $username = NULL, $password = NULL)
{
RedBean_Setup::kickstart($dsn, $username, $password);
self::$toolbox = RedBean_Setup::getToolBox();
self::$writer = self::$toolbox->getWriter();
self::$adapter = self::$toolbox->getDatabaseAdapter();
self::$redbean = self::$toolbox->getRedBean();
self::$associationManager = new RedBean_AssociationManager(self::$toolbox);
self::$treeManager = new RedBean_TreeManager(self::$toolbox);
self::$linkManager = new RedBean_LinkManager(self::$toolbox);
self::$extAssocManager = new RedBean_ExtAssociationManager(self::$toolbox);
$helper = new RedBean_ModelHelper();
self::$redbean->addEventListener("update", $helper);
self::$redbean->addEventListener("open", $helper);
self::$redbean->addEventListener("delete", $helper);
}
示例4: testTransactionInFacade
/**
* Test Facade transactions.
*
* @return void
*
* @throws Exception
*/
public function testTransactionInFacade()
{
testpack('Test transaction in facade');
$bean = R::dispense('bean');
$bean->name = 'a';
R::store($bean);
R::trash($bean);
R::freeze(TRUE);
$bean = R::dispense('bean');
$bean->name = 'a';
R::store($bean);
asrt(R::count('bean'), 1);
R::trash($bean);
asrt(R::count('bean'), 0);
$bean = R::dispense('bean');
$bean->name = 'a';
$id = R::transaction(function () use(&$bean) {
return R::transaction(function () use(&$bean) {
return R::store($bean);
});
});
asrt((int) $id, (int) $bean->id);
R::trash($bean);
$bean = R::dispense('bean');
$bean->name = 'a';
$id = R::transaction(function () use(&$bean) {
return R::store($bean);
});
asrt((int) $id, (int) $bean->id);
R::trash($bean);
$bean = R::dispense('bean');
$bean->name = 'a';
try {
R::transaction(function () use($bean) {
R::store($bean);
R::transaction(function () {
throw new Exception();
});
});
} catch (Exception $e) {
pass();
}
asrt(R::count('bean'), 0);
$bean = R::dispense('bean');
$bean->name = 'a';
try {
R::transaction(function () use($bean) {
R::transaction(function () use($bean) {
R::store($bean);
throw new Exception();
});
});
} catch (Exception $e) {
pass();
}
asrt(R::count('bean'), 0);
$bean = R::dispense('bean');
$bean->name = 'a';
try {
R::transaction(function () use($bean) {
R::transaction(function () use($bean) {
R::store($bean);
});
});
} catch (Exception $e) {
pass();
}
asrt(R::count('bean'), 1);
R::freeze(FALSE);
try {
R::transaction('nope');
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('Test debugger check.');
$old = R::$adapter;
R::$adapter = NULL;
try {
R::debug(TRUE);
fail();
} catch (RedBean_Exception_Security $e) {
pass();
}
R::$adapter = $old;
R::debug(FALSE);
//.........这里部分代码省略.........