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


PHP ObjectCollection::count方法代码示例

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


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

示例1: insertChunk

 /**
  * @param string $itemType
  * @param string $itemEvent
  * @param array $itemIds
  *
  * @return int
  */
 protected function insertChunk($itemType, $itemEvent, array $itemIds)
 {
     $propelCollection = new ObjectCollection();
     $propelCollection->setModel(SpyTouch::class);
     foreach ($itemIds as $itemId) {
         $touchEntity = new SpyTouch();
         $touchEntity->setItemEvent($itemEvent)->setItemId($itemId)->setItemType($itemType)->setTouched(new \DateTime());
         $propelCollection->append($touchEntity);
     }
     $propelCollection->save();
     return $propelCollection->count();
 }
开发者ID:spryker,项目名称:Touch,代码行数:19,代码来源:BulkTouchHandlerInsert.php

示例2: testSetterCollectionWithNoData

 public function testSetterCollectionWithNoData()
 {
     // Ensure no data
     BookQuery::create()->deleteAll();
     BookClubListQuery::create()->deleteAll();
     BookListRelQuery::create()->deleteAll();
     $books = new ObjectCollection();
     $this->assertEquals(0, $books->count());
     // Basic usage
     $bookClubList1 = new BookClubList();
     $bookClubList1->setGroupLeader('BookClubList1 Leader');
     $bookClubList1->setBooks($books);
     $bookClubList1->save();
     $this->assertEquals(0, $bookClubList1->getBooks()->count());
     $this->assertEquals(1, BookClubListQuery::create()->count());
     $this->assertEquals(0, BookQuery::create()->count());
     $this->assertEquals(0, BookListRelQuery::create()->count());
 }
开发者ID:rouffj,项目名称:Propel2,代码行数:18,代码来源:GeneratedObjectRelTest.php

示例3: testSetterOneToManyWithFkRequired

 public function testSetterOneToManyWithFkRequired()
 {
     // Ensure no data
     BookSummaryQuery::create()->deleteAll();
     BookQuery::create()->deleteAll();
     $coll = new ObjectCollection();
     $coll->setModel('BookSummary');
     for ($i = 0; $i < 3; $i++) {
         $coll[] = new BookSummary();
     }
     $this->assertEquals(3, $coll->count());
     $b = new Book();
     $b->setTitle('myBook');
     $b->setBookSummaries($coll);
     $b->save();
     $this->assertInstanceOf('Propel\\Runtime\\Collection\\ObjectCollection', $b->getBookSummaries());
     $this->assertEquals(3, $b->getBookSummaries()->count());
     $this->assertEquals(1, BookQuery::create()->count());
     $this->assertEquals(3, BookSummaryQuery::create()->count());
     $coll->shift();
     $this->assertEquals(2, $coll->count());
     $b->setBookSummaries($coll);
     $b->save();
     $this->assertEquals(2, $b->getBookSummaries()->count());
     $this->assertEquals(1, BookQuery::create()->count());
     $this->assertEquals(2, BookSummaryQuery::create()->count());
     $newBookSammary = new BookSummary();
     $newBookSammary->setSummary('My sammary');
     // Kind of new collection
     $coll = clone $coll;
     $coll[] = $newBookSammary;
     $b->setBookSummaries($coll);
     $b->save();
     $this->assertEquals(3, $coll->count());
     $this->assertEquals(3, $b->getBookSummaries()->count());
     $this->assertEquals(1, BookQuery::create()->count());
     $this->assertEquals(3, BookSummaryQuery::create()->count());
     // Add a new object
     $newBookSammary1 = new BookSummary();
     $newBookSammary1->setSummary('My sammary 1');
     // Existing collection - The fix around reference is tested here.
     $coll[] = $newBookSammary1;
     $b->setBookSummaries($coll);
     $b->save();
     $this->assertEquals(4, $coll->count());
     $this->assertEquals(4, $b->getBookSummaries()->count());
     $this->assertEquals(1, BookQuery::create()->count());
     $this->assertEquals(4, BookSummaryQuery::create()->count());
     // Add the same collection
     $bookSummaries = $b->getBookSummaries();
     $b->setBookSummaries($bookSummaries);
     $b->save();
     $this->assertEquals(4, $coll->count());
     $this->assertEquals(4, $b->getBookSummaries()->count());
     $this->assertEquals(1, BookQuery::create()->count());
     $this->assertEquals(4, BookSummaryQuery::create()->count());
 }
开发者ID:robin850,项目名称:Propel2,代码行数:57,代码来源:GeneratedObjectTest.php

示例4: testSetterOneToManyWithNoData

 public function testSetterOneToManyWithNoData()
 {
     // Ensure no data
     BookQuery::create()->deleteAll();
     AuthorQuery::create()->deleteAll();
     $books = new ObjectCollection();
     $this->assertEquals(0, $books->count());
     // Basic usage
     $a = new Author();
     $a->setBooks($books);
     $a->save();
     $this->assertEquals(0, $a->getBooks()->count());
     $this->assertEquals(1, AuthorQuery::create()->count());
     $this->assertEquals(0, BookQuery::create()->count());
 }
开发者ID:rouffj,项目名称:Propel2,代码行数:15,代码来源:GeneratedObjectTest.php


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