本文整理汇总了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();
}