當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Facade::gatherLabels方法代碼示例

本文整理匯總了PHP中RedBeanPHP\Facade::gatherLabels方法的典型用法代碼示例。如果您正苦於以下問題:PHP Facade::gatherLabels方法的具體用法?PHP Facade::gatherLabels怎麽用?PHP Facade::gatherLabels使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在RedBeanPHP\Facade的用法示例。


在下文中一共展示了Facade::gatherLabels方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testLabels

 /**
  * Test basic labels.
  *
  * @return void
  */
 public function testLabels()
 {
     testpack('Test Labels');
     $meals = R::dispenseLabels('meal', array('meat', 'fish', 'vegetarian'));
     asrt(is_array($meals), TRUE);
     asrt(count($meals), 3);
     foreach ($meals as $m) {
         asrt($m instanceof OODBBean, TRUE);
     }
     $listOfMeals = implode(',', R::gatherLabels($meals));
     asrt($listOfMeals, 'fish,meat,vegetarian');
 }
開發者ID:gabordemooij,項目名稱:redbean,代碼行數:17,代碼來源:Labels.php

示例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);
 }
開發者ID:AntonyAntonio,項目名稱:phpback,代碼行數:41,代碼來源:Misc.php

示例3: testSelfReferentialCRUD

 /**
  * Test many different scenarios with self referential
  * many-to-many relations.
  *
  * @return void
  */
 public function testSelfReferentialCRUD()
 {
     R::nuke();
     $buddies = R::dispense('buddy', 4);
     $buddies[0]->name = 'A';
     $buddies[1]->name = 'B';
     $buddies[2]->name = 'C';
     $buddies[3]->name = 'D';
     $buddies[0]->sharedBuddyList = array($buddies[1], $buddies[2]);
     $buddies[3]->sharedBuddyList = array($buddies[2]);
     R::storeAll($buddies);
     $buddies[0] = $buddies[0]->fresh();
     asrt(count($buddies[0]->sharedBuddyList), 2);
     //does this yield valid combinations - cross relations / self ref n-m
     //need to symmetric....
     $names = R::gatherLabels($buddies[0]->sharedBuddyList);
     sort($names);
     $names = implode(',', $names);
     asrt($names, 'B,C');
     unset($buddies[0]->sharedBuddy);
     R::storeAll($buddies);
     $buddies[0] = $buddies[0]->fresh();
     asrt(count($buddies[0]->sharedBuddyList), 2);
     $buddies[3] = $buddies[3]->fresh();
     asrt(count($buddies[3]->sharedBuddyList), 1);
     $names = R::gatherLabels($buddies[3]->sharedBuddyList);
     sort($names);
     $names = implode(',', $names);
     asrt($names, 'C');
     $buddies[2] = $buddies[2]->fresh();
     asrt(count($buddies[2]->sharedBuddyList), 2);
     $names = R::gatherLabels($buddies[2]->sharedBuddyList);
     sort($names);
     $names = implode(',', $names);
     asrt($names, 'A,D');
     $buddies[1] = $buddies[1]->fresh();
     asrt(count($buddies[1]->sharedBuddyList), 1);
     $names = R::gatherLabels($buddies[1]->sharedBuddyList);
     sort($names);
     $names = implode(',', $names);
     asrt($names, 'A');
     //Can we add one?
     $buddies[1]->sharedBuddyList[] = R::dispense('buddy')->setAttr('name', 'E');
     R::store($buddies[1]);
     $buddies[0] = $buddies[0]->fresh();
     asrt(count($buddies[0]->sharedBuddyList), 2);
     $names = R::gatherLabels($buddies[0]->sharedBuddyList);
     sort($names);
     $names = implode(',', $names);
     asrt($names, 'B,C');
     $buddies[1] = $buddies[1]->fresh();
     asrt(count($buddies[1]->sharedBuddyList), 2);
     $names = R::gatherLabels($buddies[1]->sharedBuddyList);
     sort($names);
     $names = implode(',', $names);
     asrt($names, 'A,E');
     $all = R::find('buddy');
     asrt(count($all), 5);
     foreach ($buddies[1]->sharedBuddy as $buddy) {
         if ($buddy->name === 'E') {
             $buddyE = $buddy;
         }
     }
     asrt(isset($buddyE), TRUE);
     asrt($buddyE->name, 'E');
     //can we update?
     foreach ($buddies[0]->sharedBuddy as $buddy) {
         if ($buddy->name === 'C') {
             $buddy->name = 'C2';
         }
     }
     R::store($buddies[0]);
     $buddies[0] = $buddies[0]->fresh();
     asrt(count($buddies[0]->sharedBuddyList), 2);
     $names = R::gatherLabels($buddies[0]->sharedBuddyList);
     sort($names);
     $names = implode(',', $names);
     asrt($names, 'B,C2');
     $buddies[2] = $buddies[2]->fresh();
     asrt(count($buddies[2]->sharedBuddyList), 2);
     $names = R::gatherLabels($buddies[2]->sharedBuddyList);
     sort($names);
     $names = implode(',', $names);
     asrt($names, 'A,D');
     //can we delete?
     foreach ($buddies[0]->sharedBuddyList as $id => $buddy) {
         if ($buddy->name === 'B') {
             unset($buddies[0]->sharedBuddyList[$id]);
         }
     }
     R::store($buddies[0]);
     $buddies[0] = $buddies[0]->fresh();
     asrt(count($buddies[0]->sharedBuddyList), 1);
     $names = R::gatherLabels($buddies[0]->sharedBuddyList);
//.........這裏部分代碼省略.........
開發者ID:diego-vieira,項目名稱:redbean,代碼行數:101,代碼來源:Cross.php

示例4: testFastTrackRelations

 /**
  * Fast track link block code should not affect self-referential N-M relations.
  *
  * @return void
  */
 public function testFastTrackRelations()
 {
     testpack('Test fast-track linkBlock exceptions');
     list($donald, $mickey, $goofy, $pluto) = R::dispense('friend', 4);
     $donald->name = 'D';
     $mickey->name = 'M';
     $goofy->name = 'G';
     $pluto->name = 'P';
     $donald->sharedFriend = array($mickey, $goofy);
     $mickey->sharedFriend = array($pluto, $goofy);
     $mickey->sharedBook = array(R::dispense('book'));
     R::storeAll(array($mickey, $donald, $goofy, $pluto));
     $donald = R::load('friend', $donald->id);
     $mickey = R::load('friend', $mickey->id);
     $goofy = R::load('friend', $goofy->id);
     $pluto = R::load('friend', $pluto->id);
     $names = implode(',', R::gatherLabels($donald->sharedFriend));
     asrt($names, 'G,M');
     $names = implode(',', R::gatherLabels($goofy->sharedFriend));
     asrt($names, 'D,M');
     $names = implode(',', R::gatherLabels($mickey->sharedFriend));
     asrt($names, 'D,G,P');
     $names = implode(',', R::gatherLabels($pluto->sharedFriend));
     asrt($names, 'M');
     // Now in combination with with() conditions...
     $donald = R::load('friend', $donald->id);
     $names = implode(',', R::gatherLabels($donald->withCondition(' name = ? ', array('M'))->sharedFriend));
     asrt($names, 'M');
     // Now in combination with with() conditions...
     $donald = R::load('friend', $donald->id);
     $names = implode(',', R::gatherLabels($donald->with(' ORDER BY name ')->sharedFriend));
     asrt($names, 'G,M');
     // Now counting
     $goofy = R::load('friend', $goofy->id);
     asrt((int) $goofy->countShared('friend'), 2);
     asrt((int) $donald->countShared('friend'), 2);
     asrt((int) $mickey->countShared('friend'), 3);
     asrt((int) $pluto->countShared('friend'), 1);
 }
開發者ID:AntonyAntonio,項目名稱:phpback,代碼行數:44,代碼來源:Relations.php


注:本文中的RedBeanPHP\Facade::gatherLabels方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。