当前位置: 首页>>代码示例>>PHP>>正文


PHP R::gatherLabels方法代码示例

本文整理汇总了PHP中R::gatherLabels方法的典型用法代码示例。如果您正苦于以下问题:PHP R::gatherLabels方法的具体用法?PHP R::gatherLabels怎么用?PHP R::gatherLabels使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在R的用法示例。


在下文中一共展示了R::gatherLabels方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 RedBean_OODBBean, TRUE);
     }
     $listOfMeals = implode(',', R::gatherLabels($meals));
     asrt($listOfMeals, 'fish,meat,vegetarian');
 }
开发者ID:daviddeutsch,项目名称:redbean-adaptive,代码行数: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:daviddeutsch,项目名称:redbean-adaptive,代码行数:41,代码来源:Misc.php

示例3: 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);
     R::unassociate($donald, $mickey);
     asrt((int) $donald->countShared('friend'), 1);
     asrt(R::areRelated($donald, $mickey), FALSE);
     asrt(R::areRelated($mickey, $donald), FALSE);
     asrt(R::areRelated($mickey, $goofy), TRUE);
     asrt(R::areRelated($goofy, $mickey), TRUE);
     R::getWriter()->setUseCache(TRUE);
     $mickeysFriends = R::$associationManager->related($mickey, 'friend', TRUE);
     asrt(count($mickeysFriends), 2);
     $mickeysFriends = R::$associationManager->related($mickey, 'friend', TRUE);
     asrt(count($mickeysFriends), 2);
     $plutosFriends = R::$associationManager->related($pluto, 'friend', TRUE);
     asrt(count($plutosFriends), 1);
     $mickeysBooks = R::$associationManager->related($mickey, 'book', TRUE);
     asrt(count($mickeysBooks), 1);
     R::getWriter()->setUseCache(FALSE);
 }
开发者ID:daviddeutsch,项目名称:redbean-adaptive,代码行数:60,代码来源:Relations.php


注:本文中的R::gatherLabels方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。