本文整理汇总了PHP中RedBeanPHP\Facade::wipe方法的典型用法代码示例。如果您正苦于以下问题:PHP Facade::wipe方法的具体用法?PHP Facade::wipe怎么用?PHP Facade::wipe使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RedBeanPHP\Facade
的用法示例。
在下文中一共展示了Facade::wipe方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testBatch
/**
* Begin testing.
* This method runs the actual test pack.
*
* @return void
*/
public function testBatch()
{
R::freeze(FALSE);
$toolbox = R::getToolBox();
$adapter = $toolbox->getDatabaseAdapter();
$writer = $toolbox->getWriter();
$redbean = $toolbox->getRedBean();
$pdo = $adapter->getDatabase();
$page = $redbean->dispense("page");
$page->name = "page no. 1";
$page->rating = 1;
$id1 = $redbean->store($page);
$page = $redbean->dispense("page");
$page->name = "page no. 2";
$id2 = $redbean->store($page);
$batch = $redbean->batch("page", array($id1, $id2));
asrt(count($batch), 2);
asrt($batch[$id1]->getMeta("type"), "page");
asrt($batch[$id2]->getMeta("type"), "page");
asrt((int) $batch[$id1]->id, $id1);
asrt((int) $batch[$id2]->id, $id2);
$book = $redbean->dispense("book");
$book->name = "book 1";
$redbean->store($book);
$book = $redbean->dispense("book");
$book->name = "book 2";
$redbean->store($book);
$book = $redbean->dispense("book");
$book->name = "book 3";
$redbean->store($book);
$books = $redbean->batch("book", $adapter->getCol("SELECT id FROM book"));
asrt(count($books), 3);
$a = $redbean->batch('book', 9919);
asrt(is_array($a), TRUE);
asrt(count($a), 0);
$a = $redbean->batch('triangle', 1);
asrt(is_array($a), TRUE);
asrt(count($a), 0);
R::freeze(TRUE);
$a = $redbean->batch('book', 9919);
asrt(is_array($a), TRUE);
asrt(count($a), 0);
try {
$a = $redbean->batch('triangle', 1);
fail();
} catch (SQL $e) {
pass();
}
R::freeze(FALSE);
asrt(R::wipe('spaghettimonster'), FALSE);
}
示例2: testCountAndWipe
/**
* Test count and wipe.
*
* @return void
*/
public function testCountAndWipe()
{
testpack("Test count and wipe");
$page = R::dispense("page");
$page->name = "ABC";
R::store($page);
$n1 = R::count("page");
$page = R::dispense("page");
$page->name = "DEF";
R::store($page);
$n2 = R::count("page");
asrt($n1 + 1, $n2);
R::wipe("page");
asrt(R::count("page"), 0);
asrt(R::getRedBean()->count("page"), 0);
asrt(R::getRedBean()->count("kazoo"), 0);
// non existing table
R::freeze(TRUE);
asrt(R::getRedBean()->count("kazoo"), 0);
// non existing table
R::freeze(FALSE);
$page = R::dispense('page');
$page->name = 'foo';
R::store($page);
$page = R::dispense('page');
$page->name = 'bar';
R::store($page);
asrt(R::count('page', ' name = ? ', array('foo')), 1);
// Now count something that does not exist, this should return 0. (just be polite)
asrt(R::count('teapot', ' name = ? ', array('flying')), 0);
asrt(R::count('teapot'), 0);
$currentDriver = $this->currentlyActiveDriverID;
// Some drivers don't support that many error codes.
if ($currentDriver === 'mysql' || $currentDriver === 'postgres') {
try {
R::count('teaport', ' for tea ');
fail();
} catch (SQL $e) {
pass();
}
}
}
示例3: testTransactions
/**
* Test Transactions.
*
* @return void
*/
public function testTransactions()
{
testpack('transactions');
R::begin();
$bean = R::dispense('bean');
R::store($bean);
R::commit();
asrt(R::count('bean'), 1);
R::wipe('bean');
R::freeze(1);
R::begin();
$bean = R::dispense('bean');
R::store($bean);
R::rollback();
asrt(R::count('bean'), 0);
R::freeze(FALSE);
testpack('genSlots');
asrt(R::genSlots(array('a', 'b')), '?,?');
asrt(R::genSlots(array('a')), '?');
asrt(R::genSlots(array()), '');
}
示例4: clearsystemlog
public static function clearsystemlog($userid)
{
if (self::if_table_exists('systemlog')) {
$rs = R::wipe('systemlog');
return $rs;
} else {
self::createSystemlog();
return 0;
}
}