本文整理匯總了PHP中RedBeanPHP\Facade::enum方法的典型用法代碼示例。如果您正苦於以下問題:PHP Facade::enum方法的具體用法?PHP Facade::enum怎麽用?PHP Facade::enum使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類RedBeanPHP\Facade
的用法示例。
在下文中一共展示了Facade::enum方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: EID
function EID($enumName)
{
return \RedBeanPHP\Facade::enum($enumName)->id;
}
示例2: testENUM
/**
* Test ENUM functionality offered by Label Maker.
*
* @return void
*/
public function testENUM()
{
testpack('test ENUM');
$coffee = R::dispense('coffee');
$coffee->taste = R::enum('flavour:mocca');
//did we create an enum?
asrt(implode('', R::gatherLabels(R::enum('flavour'))), 'MOCCA');
R::store($coffee);
$coffee = $coffee->fresh();
//test enum identity check - with alias
asrt($coffee->fetchAs('flavour')->taste->equals(R::enum('flavour:mocca')), TRUE);
asrt($coffee->fetchAs('flavour')->taste->equals(R::enum('flavour:banana')), FALSE);
//now we have two flavours
asrt(R::count('flavour'), 2);
asrt(implode(',', R::gatherLabels(R::enum('flavour'))), 'BANANA,MOCCA');
$coffee->flavour = R::enum('flavour:mocca');
R::store($coffee);
//same results, can we have multiple flavours?
asrt($coffee->fetchAs('flavour')->taste->equals(R::enum('flavour:mocca')), TRUE);
asrt($coffee->fetchAs('flavour')->taste->equals(R::enum('flavour:banana')), FALSE);
asrt($coffee->flavour->equals(R::enum('flavour:mocca')), TRUE);
//no additional mocca enum...
asrt(R::count('flavour'), 2);
$drink = R::dispense('drink');
$drink->flavour = R::enum('flavour:choco');
R::store($drink);
//now we have three!
asrt(R::count('flavour'), 3);
$drink = R::load('drink', $drink->id);
asrt($drink->flavour->equals(R::enum('flavour:mint')), FALSE);
asrt($drink->flavour->equals(R::enum('flavour:choco')), TRUE);
asrt(R::count('flavour'), 4);
//trash should not affect flavour!
R::trash($drink);
asrt(R::count('flavour'), 4);
}