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


PHP ObjectCollection::save方法代碼示例

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


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

示例1: testWithPaginate

 public function testWithPaginate()
 {
     QuerycacheTable1Query::create()->deleteAll();
     $coll = new ObjectCollection();
     $coll->setModel('\\Propel\\Tests\\Bookstore\\Behavior\\QuerycacheTable1');
     for ($i = 0; $i < 5; $i++) {
         $b = new QuerycacheTable1();
         $b->setTitle('Title' . $i);
         $coll[] = $b;
     }
     $coll->save();
     $pager = $this->getPager(2, 1);
     $this->assertEquals(5, $pager->getNbResults());
     $results = $pager->getResults();
     $this->assertEquals('query cache with paginate offset 0 limit 2', $pager->getQuery()->getQueryKey());
     $this->assertEquals(2, count($results));
     $this->assertEquals('Title1', $results[1]->getTitle());
     //jump to page 3
     $pager = $this->getPager(2, 3);
     $this->assertEquals(5, $pager->getNbResults());
     $results = $pager->getResults();
     $this->assertEquals('query cache with paginate offset 4 limit 2', $pager->getQuery()->getQueryKey());
     $this->assertEquals(1, count($results));
     $this->assertEquals('Title4', $results[0]->getTitle());
 }
開發者ID:naldz,項目名稱:cyberden,代碼行數:25,代碼來源:QueryCacheTest.php

示例2: testSaveOnReadOnlyEntityThrowsException

 /**
  * @expectedException \Propel\Runtime\Exception\PropelException
  */
 public function testSaveOnReadOnlyEntityThrowsException()
 {
     $col = new ObjectCollection();
     $col->setModel('\\Propel\\Tests\\Bookstore\\ContestView');
     $cv = new ContestView();
     $col[] = $cv;
     $col->save();
 }
開發者ID:norfil,項目名稱:Propel2,代碼行數:11,代碼來源:ObjectCollectionTest.php

示例3: createBooks

 protected function createBooks($nb = 15, $con = null)
 {
     BookQuery::create()->deleteAll($con);
     $books = new ObjectCollection();
     $books->setModel('\\Propel\\Tests\\Bookstore\\Book');
     for ($i = 0; $i < $nb; $i++) {
         $b = new Book();
         $b->setTitle('Book' . $i);
         $books[] = $b;
     }
     $books->save($con);
 }
開發者ID:norfil,項目名稱:Propel2,代碼行數:12,代碼來源:PropelModelPagerTest.php

示例4: 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

示例5: testFromArray

 public function testFromArray()
 {
     $author = new Author();
     $author->setFirstName('Jane');
     $author->setLastName('Austen');
     $author->save();
     $books = array(array('Title' => 'Mansfield Park', 'ISBN' => 'FA404', 'AuthorId' => $author->getId()), array('Title' => 'Pride And Prejudice', 'ISBN' => 'FA404', 'AuthorId' => $author->getId()));
     $col = new ObjectCollection();
     $col->setModel('Propel\\Tests\\Bookstore\\Book');
     $col->fromArray($books);
     $col->save();
     $nbBooks = PropelQuery::from('Propel\\Tests\\Bookstore\\Book')->count();
     $this->assertEquals(6, $nbBooks);
     $booksByJane = PropelQuery::from('Propel\\Tests\\Bookstore\\Book b')->join('b.Author a')->where('a.LastName = ?', 'Austen')->count();
     $this->assertEquals(2, $booksByJane);
 }
開發者ID:dracony,項目名稱:forked-php-orm-benchmark,代碼行數:16,代碼來源:ObjectCollectionWithFixturesTest.php

示例6: save

 public function save($key = null)
 {
     if ($key === null) {
         $data = [];
         foreach (array_keys($this->preferences) as $key) {
             $data[] = $this->getPreference($key);
         }
         $collection = new ObjectCollection($data);
         $collection->setModel(PreferenceTableMap::CLASS_NAME);
         $collection->save();
     } else {
         if ($this->has($key)) {
             $p = $this->getPreference($key);
             $p->save();
         }
     }
 }
開發者ID:keeko,項目名稱:framework,代碼行數:17,代碼來源:Preferences.php

示例7: populateCreatedAt

 protected function populateCreatedAt()
 {
     Table2Query::create()->deleteAll();
     $ts = new ObjectCollection();
     $ts->setModel('\\Propel\\Tests\\Bookstore\\Behavior\\Table2');
     for ($i = 0; $i < 10; $i++) {
         $t = new Table2();
         $t->setTitle('CreatedAt' . $i);
         $t->setCreatedAt(time() - $i * 24 * 60 * 60 - 30);
         $ts[] = $t;
     }
     $ts->save();
 }
開發者ID:malukenho,項目名稱:Propel2,代碼行數:13,代碼來源:TimestampableBehaviorTest.php


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