當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。