本文整理匯總了PHP中PropelObjectCollection::save方法的典型用法代碼示例。如果您正苦於以下問題:PHP PropelObjectCollection::save方法的具體用法?PHP PropelObjectCollection::save怎麽用?PHP PropelObjectCollection::save使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PropelObjectCollection
的用法示例。
在下文中一共展示了PropelObjectCollection::save方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testSaveOnReadOnlyEntityThrowsException
/**
* @expectedException PropelException
*/
public function testSaveOnReadOnlyEntityThrowsException()
{
$col = new PropelObjectCollection();
$col->setModel('ContestView');
$cv = new ContestView();
$col[] = $cv;
$col->save();
}
示例2: createBooks
protected function createBooks($nb = 15, $con = null)
{
BookQuery::create()->deleteAll($con);
$books = new PropelObjectCollection();
$books->setModel('Book');
for ($i = 0; $i < $nb; $i++) {
$b = new Book();
$b->setTitle('Book' . $i);
$books[] = $b;
}
$books->save($con);
}
示例3: testFromArray
public function testFromArray()
{
$author = new Author();
$author->setFirstName('Jane');
$author->setLastName('Austen');
$author->save();
$books = array(array('Title' => 'Mansfield Park', 'AuthorId' => $author->getId()), array('Title' => 'Pride And PRejudice', 'AuthorId' => $author->getId()));
$col = new PropelObjectCollection();
$col->setModel('Book');
$col->fromArray($books);
$col->save();
$nbBooks = PropelQuery::from('Book')->count();
$this->assertEquals(6, $nbBooks);
$booksByJane = PropelQuery::from('Book b')->join('b.Author a')->where('a.LastName = ?', 'Austen')->count();
$this->assertEquals(2, $booksByJane);
}
示例4: populateCreatedAt
protected function populateCreatedAt()
{
Table2Query::create()->deleteAll();
$ts = new PropelObjectCollection();
$ts->setModel('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();
}