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


PHP Facade::batch方法代码示例

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


在下文中一共展示了Facade::batch方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testCachingEffects

 /**
  * Test effects of cache.
  * 
  * @return void
  */
 public function testCachingEffects()
 {
     testpack('Testing WriteCache Query Writer Cache');
     R::useWriterCache(FALSE);
     R::debug(true, 1);
     $logger = R::getDatabaseAdapter()->getDatabase()->getLogger();
     $book = R::dispense('book')->setAttr('title', 'ABC');
     $book->ownPage[] = R::dispense('page');
     $id = R::store($book);
     // Test load cache -- without
     $logger->clear();
     $book = R::load('book', $id);
     $book = R::load('book', $id);
     asrt(count($logger->grep('SELECT')), 2);
     // With cache
     R::useWriterCache(TRUE);
     $logger->clear();
     $book = R::load('book', $id);
     $book = R::load('book', $id);
     asrt(count($logger->grep('SELECT')), 1);
     R::useWriterCache(FALSE);
     // Test find cache
     $logger->clear();
     $book = R::find('book');
     $book = R::find('book');
     asrt(count($logger->grep('SELECT')), 2);
     // With cache
     R::getWriter()->setUseCache(TRUE);
     $logger->clear();
     $book = R::find('book');
     $book = R::find('book');
     asrt(count($logger->grep('SELECT')), 1);
     R::getWriter()->setUseCache(FALSE);
     // Test combinations
     $logger->clear();
     $book = R::findOne('book', ' id = ? ', array($id));
     $book->ownPage;
     R::batch('book', array($id));
     $book = R::findOne('book', ' id = ? ', array($id));
     $book->ownPage;
     R::batch('book', array($id));
     asrt(count($logger->grep('SELECT')), 6);
     // With cache
     R::getWriter()->setUseCache(TRUE);
     $logger->clear();
     R::batch('book', array($id));
     $book = R::findOne('book', ' id = ? ', array($id));
     $book->ownPage;
     $book = R::findOne('book', ' id = ? ', array($id));
     $book->ownPage;
     asrt(count($logger->grep('SELECT')), 3);
     R::getWriter()->setUseCache(FALSE);
     // Test auto flush
     $logger->clear();
     $book = R::findOne('book');
     $book->name = 'X';
     R::store($book);
     $book = R::findOne('book');
     asrt(count($logger->grep('SELECT *')), 2);
     // With cache
     R::getWriter()->setUseCache(TRUE);
     $logger->clear();
     $book = R::findOne('book');
     $book->name = 'Y';
     // Will flush
     R::store($book);
     $book = R::findOne('book');
     // Now the same, auto flushed
     asrt(count($logger->grep('SELECT *')), 2);
     R::getWriter()->setUseCache(FALSE);
     // Test whether delete flushes as well (because uses selectRecord - might be a gotcha!)
     R::store(R::dispense('garbage'));
     $garbage = R::findOne('garbage');
     $logger->clear();
     $book = R::findOne('book');
     R::trash($garbage);
     $book = R::findOne('book');
     asrt(count($logger->grep('SELECT *')), 2);
     R::store(R::dispense('garbage'));
     $garbage = R::findOne('garbage');
     // With cache
     R::getWriter()->setUseCache(TRUE);
     $logger->clear();
     $book = R::findOne('book');
     R::trash($garbage);
     $book = R::findOne('book');
     // Now the same, auto flushed
     asrt(count($logger->grep('SELECT *')), 2);
     R::getWriter()->setUseCache(FALSE);
     R::store(R::dispense('garbage'));
     $garbage = R::findOne('garbage');
     // With cache
     R::getWriter()->setUseCache(TRUE);
     $logger->clear();
     $book = R::findOne('book');
//.........这里部分代码省略.........
开发者ID:skullyframework,项目名称:skully,代码行数:101,代码来源:Writecache.php

示例2: testMultiDeleteUpdate

 /**
  * Test trashAll().
  */
 public function testMultiDeleteUpdate()
 {
     testpack('test multi delete and multi update');
     $beans = R::dispenseLabels('bean', array('a', 'b'));
     $ids = R::storeAll($beans);
     asrt((int) R::count('bean'), 2);
     R::trashAll(R::batch('bean', $ids));
     asrt((int) R::count('bean'), 0);
     testpack('test assocManager check');
     $rb = new OODB(R::getWriter());
     try {
         $rb->getAssociationManager();
         fail();
     } catch (RedException $e) {
         pass();
     }
 }
开发者ID:AntonyAntonio,项目名称:phpback,代码行数:20,代码来源:Misc.php

示例3: testFullSupport


//.........这里部分代码省略.........
     }
     asrt(!is_null($blueRoom), TRUE);
     asrt(is_array($blueRoom->sharedGhostList), TRUE);
     asrt(count($blueRoom->sharedGhostList), 3);
     $names = array();
     foreach ($blueRoom->sharedGhost as $ghost) {
         $names[] = $ghost->name;
     }
     sort($names);
     $names = implode(',', $names);
     asrt($names, 'one,three,two');
     $rooms = $haunted->xownRoomList;
     $redRoom = NULL;
     foreach ($rooms as $room) {
         if ($room->name === 'Red Room') {
             $redRoom = $room;
             break;
         }
     }
     $names = array();
     foreach ($redRoom->sharedGhost as $ghost) {
         $names[] = $ghost->name;
     }
     sort($names);
     $names = implode(',', $names);
     asrt($names, 'two,zero');
     asrt(!is_null($redRoom), TRUE);
     asrt(is_array($redRoom->sharedGhostList), TRUE);
     asrt(count($redRoom->sharedGhostList), 2);
     //Can we repaint a room?
     $redRoom->name = 'Yellow Room';
     $id = R::store($redRoom);
     $yellowRoom = R::load('room', $id);
     asrt($yellowRoom->name, 'Yellow Room');
     asrt(!is_null($yellowRoom), TRUE);
     asrt(is_array($yellowRoom->sharedGhostList), TRUE);
     asrt(count($yellowRoom->sharedGhostList), 2);
     //Can we throw one ghost out?
     array_pop($yellowRoom->sharedGhost);
     R::store($yellowRoom);
     $yellowRoom = $yellowRoom->fresh();
     asrt($yellowRoom->name, 'Yellow Room');
     asrt(!is_null($yellowRoom), TRUE);
     asrt(is_array($yellowRoom->sharedGhostList), TRUE);
     asrt(count($yellowRoom->sharedGhostList), 1);
     //can we remove one of the rooms?
     asrt(R::count('key'), 1);
     $list = $mansion->withCondition(' "name" = ? ', array('Blue Room'))->xownRoomList;
     $room = reset($list);
     unset($mansion->xownRoomList[$room->id]);
     R::store($mansion);
     asrt(R::count('room'), 2);
     //and what about its dependent beans?
     asrt(R::count('key'), 0);
     asrt(R::count('ghost_room'), 3);
     //and can we find ghosts?
     $ghosts = R::find('ghost');
     asrt(count($ghosts), 4);
     $ghosts = R::findAll('ghost', 'ORDER BY id');
     asrt(count($ghosts), 4);
     $ghosts = R::findAll('ghost', 'ORDER BY id LIMIT 2');
     asrt(count($ghosts), 2);
     $ghostZero = R::findOne('ghost', ' "name" = ? ', array('zero'));
     asrt($ghostZero instanceof OODBBean, TRUE);
     //can we create link properties on existing tables?
     $blackRoom = R::dispense('room');
     $blackRoom->name = 'Black Room';
     $ghostZero->link('ghost_room', array('mood' => 'grumpy'))->room = $blackRoom;
     R::store($ghostZero);
     $ghostZero = $ghostZero->fresh();
     $list = $ghostZero->sharedRoomList;
     asrt(count($list), 3);
     $ghostZero = $ghostZero->fresh();
     $list = $ghostZero->withCondition(' ghost_room.mood = ? ', array('grumpy'))->sharedRoomList;
     asrt(count($list), 1);
     //can we load a batch?
     $ids = R::getCol('SELECT id FROM ghost');
     $ghosts = R::batch('ghost', $ids);
     asrt(count($ghosts), 4);
     //can we do an aggregation?
     $ghosts = $greenRoom->aggr('ownGhostRoom', 'ghost', 'ghost');
     asrt(count($ghosts), 2);
     //can we duplicate the mansion?
     asrt(R::count('mansion'), 1);
     asrt(R::count('room'), 3);
     asrt(R::count('ghost'), 4);
     $copy = R::dup($mansion);
     R::store($copy);
     asrt(R::count('mansion'), 2);
     asrt(R::count('room'), 5);
     //black room does not belong to mansion 1
     asrt(R::count('ghost'), 4);
     //can we do some counting using the list?
     asrt($copy->countOwn('room'), 2);
     $rooms = $copy->withCondition(' "name" = ? ', array('Green Room'))->xownRoomList;
     $room = reset($rooms);
     asrt($room->countShared('ghost'), 2);
     //Finally restore old toolbox
     R::configureFacadeWithToolbox($oldToolBox);
 }
开发者ID:gabordemooij,项目名称:redbean,代码行数:101,代码来源:Uuid.php

示例4: testMissingBeans

 /**
  * Test missing bean scenarios.
  *
  * @return void
  */
 public function testMissingBeans()
 {
     testpack('deal with missing beans');
     $id = R::store(R::dispense('beer'));
     $bottles = R::batch('beer', array($id, $id + 1, $id + 2));
     asrt(count($bottles), 3);
     asrt((int) $bottles[$id]->id, (int) $id);
     asrt((int) $bottles[$id + 1]->id, 0);
     asrt((int) $bottles[$id + 2]->id, 0);
 }
开发者ID:gabordemooij,项目名称:redbean,代码行数:15,代码来源:Batch.php

示例5: testBatch0

 /**
  * Test whether batch still works if no IDs have been passed.
  * 
  * @return void
  */
 public function testBatch0()
 {
     $zero = R::batch('page', array());
     asrt(is_array($zero), TRUE);
     asrt(count($zero), 0);
     $zero = R::batch('page', FALSE);
     asrt(is_array($zero), TRUE);
     asrt(count($zero), 0);
     $zero = R::batch('page', NULL);
     asrt(is_array($zero), TRUE);
     asrt(count($zero), 0);
 }
开发者ID:skullyframework,项目名称:skully,代码行数:17,代码来源:Misc.php


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