本文整理匯總了PHP中Propel\Tests\Bookstore\Book::clear方法的典型用法代碼示例。如果您正苦於以下問題:PHP Book::clear方法的具體用法?PHP Book::clear怎麽用?PHP Book::clear使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Propel\Tests\Bookstore\Book
的用法示例。
在下文中一共展示了Book::clear方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testFormatALotOfResults
public function testFormatALotOfResults()
{
$nbBooks = 50;
$con = Propel::getConnection(BookPeer::DATABASE_NAME);
Propel::disableInstancePooling();
$book = new Book();
for ($i = 0; $i < $nbBooks; $i++) {
$book->clear();
$book->setTitle('BookTest' . $i);
$book->save($con);
}
$stmt = $con->query('SELECT * FROM book');
$formatter = new PropelOnDemandFormatter();
$formatter->init(new ModelCriteria('bookstore', 'Book'));
$books = $formatter->format($stmt);
$this->assertTrue($books instanceof PropelOnDemandCollection, 'PropelOnDemandFormatter::format() returns a PropelOnDemandCollection');
$this->assertEquals($nbBooks, count($books), 'PropelOnDemandFormatter::format() returns a collection that counts as many rows as the results in the query');
$i = 0;
foreach ($books as $book) {
$this->assertTrue($book instanceof Book, 'PropelOnDemandFormatter::format() returns a collection of Model objects');
$this->assertEquals('BookTest' . $i, $book->getTitle(), 'PropelOnDemandFormatter::format() returns the model objects matching the query');
$i++;
}
Propel::enableInstancePooling();
}
示例2: testClear
public function testClear()
{
$b = new Book();
$b->setNew(false);
$b->clear();
$this->assertTrue($b->isNew(), 'clear() sets the object to new');
$b = new Book();
$b->setDeleted(true);
$b->clear();
$this->assertFalse($b->isDeleted(), 'clear() sets the object to not deleted');
}
示例3: testClearCrossFk
/**
* Test the clearing of related object collection via a many-to-many association.
* @link http://www.propelorm.org/ticket/1374
*/
public function testClearCrossFk()
{
$book = new Book();
$bookClub = new BookClubList();
$book->addBookClubList($bookClub);
$this->assertEquals(1, count($book->getBookClubLists()));
$book->clear();
$this->assertEquals(0, count($book->getBookClubLists()));
}
示例4: testFormatALotOfResults
public function testFormatALotOfResults()
{
$nbBooks = 50;
$con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME);
Propel::disableInstancePooling();
$book = new Book();
for ($i = 0; $i < $nbBooks; $i++) {
$book->clear();
$book->setTitle('BookTest' . $i);
$book->setISBN('FA404-' . $i);
$book->save($con);
}
$stmt = $con->query('SELECT id, title, isbn, price, publisher_id, author_id FROM book ORDER BY book.ID ASC');
$formatter = new OnDemandFormatter();
$formatter->init(new ModelCriteria('bookstore', 'Propel\\Tests\\Bookstore\\Book'));
$books = $formatter->format($stmt);
$this->assertTrue($books instanceof OnDemandCollection, 'OnDemandFormatter::format() returns a PropelOnDemandCollection');
$this->assertEquals($nbBooks, count($books), 'OnDemandFormatter::format() returns a collection that counts as many rows as the results in the query');
$i = 0;
foreach ($books as $book) {
$this->assertTrue($book instanceof Book, 'OnDemandFormatter::format() returns a collection of Model objects');
$this->assertEquals('BookTest' . $i, $book->getTitle(), 'OnDemandFormatter::format() returns the model objects matching the query');
$i++;
}
Propel::enableInstancePooling();
}