本文整理汇总了PHP中Book::setPrice方法的典型用法代码示例。如果您正苦于以下问题:PHP Book::setPrice方法的具体用法?PHP Book::setPrice怎么用?PHP Book::setPrice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Book
的用法示例。
在下文中一共展示了Book::setPrice方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: runBookInsertion
function runBookInsertion($i)
{
$book = new Book();
$book->setTitle('Hello' . $i);
$book->setAuthorId($this->authors[array_rand($this->authors)]);
$book->setISBN('1234');
$book->setPrice($i);
$book->save($this->con);
$this->books[] = $book->getId();
}
示例2: runBookInsertion
function runBookInsertion($i)
{
$rand = array_rand($this->authors);
$book = new Book();
$book->setTitle('Hello' . $i);
$book->setAuthor($this->authors[$rand]);
$book->setISBN('1234');
$book->setPrice($i);
$this->session->persist($book);
$this->session->persist($this->authors[$rand]);
$this->books[] = $book;
$this->i++;
if ($this->i >= 500) {
$this->commit();
$this->beginTransaction();
}
}
示例3: testCloneContainingObjects
public function testCloneContainingObjects()
{
$a = new Author();
$b = new Book();
$b->setAuthor($a);
$b->setISBN('ISBN1');
$b1 = new Book();
$b1->setPrice(5.55);
$col = new PropelCollection(array($b, $b1));
$clone = clone $col;
$orgCount = $col->getIterator()->count();
$cloneCount = $clone->getIterator()->count();
$this->assertEquals($orgCount, $cloneCount, 'cloned collections have the same size');
$this->assertEquals($b, $clone[0], 'cloned objects are equal');
$this->assertEquals($b1, $clone[1], 'cloned objects are equal');
$this->assertNotSame($b, $clone[0], 'cloned objects are copies, not identical');
$this->assertNotSame($b1, $clone[1], 'cloned objects are copies, not identical');
}
示例4: setUp
protected function setUp()
{
parent::setUp();
$publisher = new Publisher();
$publisher->setId(1234);
$publisher->setName('Penguin');
$author = new Author();
$author->setId(5678);
$author->setFirstName('George');
$author->setLastName('Byron');
$book = new Book();
$book->setId(9012);
$book->setTitle('Don Juan');
$book->setISBN('0140422161');
$book->setPrice(12.99);
$book->setAuthor($author);
$book->setPublisher($publisher);
$this->book = $book;
}
示例5: setUp
protected function setUp()
{
parent::setUp();
$book1 = new Book();
$book1->setId(9012);
$book1->setTitle('Don Juan');
$book1->setISBN('0140422161');
$book1->setPrice(12.99);
$book1->setAuthorId(5678);
$book1->setPublisherId(1234);
$book1->resetModified();
$book2 = new Book();
$book2->setId(58);
$book2->setTitle('Harry Potter and the Order of the Phoenix');
$book2->setISBN('043935806X');
$book2->setPrice(10.99);
$book2->resetModified();
$this->coll = new PropelObjectCollection();
$this->coll->setModel('Book');
$this->coll[] = $book1;
$this->coll[] = $book2;
}
示例6: testFindOneOrCreateMakesOneQueryWhenRecordExists
public function testFindOneOrCreateMakesOneQueryWhenRecordExists()
{
$con = Propel::getConnection(BookPeer::DATABASE_NAME);
BookQuery::create()->deleteAll($con);
$book = new Book();
$book->setPrice(125);
$book->save($con);
$count = $con->getQueryCount();
$book = BookQuery::create('b')->filterByPrice(125)->findOneOrCreate($con);
$this->assertEquals($count + 1, $con->getQueryCount(), 'findOneOrCreate() makes only a single query when the record exists');
}
示例7: testFindOneOrCreateExists
public function testFindOneOrCreateExists()
{
BookQuery::create()->deleteAll();
$book = new Book();
$book->setTitle('foo');
$book->setPrice(125);
$book->save();
$book = BookQuery::create('b')->where('b.Title = ?', 'foo')->filterByPrice(125)->findOneOrCreate();
$this->assertTrue($book instanceof Book, 'findOneOrCreate() returns an instance of the model when the request has one result');
$this->assertFalse($book->isNew(), 'findOneOrCreate() returns an existing instance of the model when the request has one result');
$this->assertEquals('foo', $book->getTitle(), 'findOneOrCreate() returns a populated objects based on the conditions');
$this->assertEquals(125, $book->getPrice(), 'findOneOrCreate() returns a populated objects based on the conditions');
}
示例8: testToArrayDeep
public function testToArrayDeep()
{
$author = new Author();
$author->setId(5678);
$author->setFirstName('George');
$author->setLastName('Byron');
$book = new Book();
$book->setId(9012);
$book->setTitle('Don Juan');
$book->setISBN('0140422161');
$book->setPrice(12.99);
$book->setAuthor($author);
$coll = new PropelArrayCollection();
$coll->setModel('Book');
$coll[] = $book->toArray(BasePeer::TYPE_PHPNAME, true, array(), true);
$expected = array(array('Id' => 9012, 'Title' => 'Don Juan', 'ISBN' => '0140422161', 'Price' => 12.99, 'PublisherId' => null, 'AuthorId' => 5678, 'Author' => array('Id' => 5678, 'FirstName' => 'George', 'LastName' => 'Byron', 'Email' => null, 'Age' => null, 'Books' => array('Book_0' => '*RECURSION*'))));
$this->assertEquals($expected, $coll->toArray());
}
示例9: populate
public static function populate($con = null)
{
if ($con === null) {
$con = Propel::getConnection(BookPeer::DATABASE_NAME);
}
$con->beginTransaction();
// Add publisher records
// ---------------------
$scholastic = new Publisher();
$scholastic->setName("Scholastic");
// do not save, will do later to test cascade
$morrow = new Publisher();
$morrow->setName("William Morrow");
$morrow->save($con);
$morrow_id = $morrow->getId();
$penguin = new Publisher();
$penguin->setName("Penguin");
$penguin->save();
$penguin_id = $penguin->getId();
$vintage = new Publisher();
$vintage->setName("Vintage");
$vintage->save($con);
$vintage_id = $vintage->getId();
$rowling = new Author();
$rowling->setFirstName("J.K.");
$rowling->setLastName("Rowling");
// no save()
$stephenson = new Author();
$stephenson->setFirstName("Neal");
$stephenson->setLastName("Stephenson");
$stephenson->save($con);
$stephenson_id = $stephenson->getId();
$byron = new Author();
$byron->setFirstName("George");
$byron->setLastName("Byron");
$byron->save($con);
$byron_id = $byron->getId();
$grass = new Author();
$grass->setFirstName("Gunter");
$grass->setLastName("Grass");
$grass->save($con);
$grass_id = $grass->getId();
$phoenix = new Book();
$phoenix->setTitle("Harry Potter and the Order of the Phoenix");
$phoenix->setISBN("043935806X");
$phoenix->setAuthor($rowling);
$phoenix->setPublisher($scholastic);
$phoenix->setPrice(10.99);
$phoenix->save($con);
$phoenix_id = $phoenix->getId();
$qs = new Book();
$qs->setISBN("0380977427");
$qs->setTitle("Quicksilver");
$qs->setPrice(11.99);
$qs->setAuthor($stephenson);
$qs->setPublisher($morrow);
$qs->save($con);
$qs_id = $qs->getId();
$dj = new Book();
$dj->setISBN("0140422161");
$dj->setTitle("Don Juan");
$dj->setPrice(12.99);
$dj->setAuthor($byron);
$dj->setPublisher($penguin);
$dj->save($con);
$dj_id = $dj->getId();
$td = new Book();
$td->setISBN("067972575X");
$td->setTitle("The Tin Drum");
$td->setPrice(13.99);
$td->setAuthor($grass);
$td->setPublisher($vintage);
$td->save($con);
$td_id = $td->getId();
$r1 = new Review();
$r1->setBook($phoenix);
$r1->setReviewedBy("Washington Post");
$r1->setRecommended(true);
$r1->setReviewDate(time());
$r1->save($con);
$r1_id = $r1->getId();
$r2 = new Review();
$r2->setBook($phoenix);
$r2->setReviewedBy("New York Times");
$r2->setRecommended(false);
$r2->setReviewDate(time());
$r2->save($con);
$r2_id = $r2->getId();
$blob_path = _LOB_SAMPLE_FILE_PATH . '/tin_drum.gif';
$clob_path = _LOB_SAMPLE_FILE_PATH . '/tin_drum.txt';
$m1 = new Media();
$m1->setBook($td);
$m1->setCoverImage(file_get_contents($blob_path));
// CLOB is broken in PDO OCI, see http://pecl.php.net/bugs/bug.php?id=7943
if (get_class(Propel::getDB()) != "DBOracle") {
$m1->setExcerpt(file_get_contents($clob_path));
}
$m1->save($con);
// Add book list records
// ---------------------
//.........这里部分代码省略.........
示例10: testToKeyValue
public function testToKeyValue()
{
$author = new Author();
$author->setId(5678);
$author->setFirstName('George');
$author->setLastName('Byron');
$book = new Book();
$book->setId(9012);
$book->setTitle('Don Juan');
$book->setISBN('0140422161');
$book->setPrice(12.99);
$book->setAuthor($author);
$coll = new PropelObjectCollection();
$coll->setModel('Book');
$coll->append($book);
$this->assertCount(1, $coll);
// This will call $book->getId()
$this->assertEquals(array(9012 => 'Don Juan'), $coll->toKeyValue('Id', 'Title'));
// This will call: $book->getAuthor()->getBooks()->getFirst()->getId()
$this->assertEquals(array(9012 => 'Don Juan'), $coll->toKeyValue(array('Author', 'Books', 'First', 'Id'), 'Title'));
}
示例11: testFindOneWithLeftJoinWithOneToManyAndNullObjectsAndWithAdditionalJoins
public function testFindOneWithLeftJoinWithOneToManyAndNullObjectsAndWithAdditionalJoins()
{
BookPeer::clearInstancePool();
AuthorPeer::clearInstancePool();
BookOpinionPeer::clearInstancePool();
BookReaderPeer::clearInstancePool();
$freud = new Author();
$freud->setFirstName("Sigmund");
$freud->setLastName("Freud");
$freud->save($this->con);
$publisher = new Publisher();
$publisher->setName('Psycho Books');
$publisher->save();
$book = new Book();
$book->setAuthor($freud);
$book->setTitle('Weirdness');
$book->setIsbn('abc123456');
$book->setPrice('14.99');
$book->setPublisher($publisher);
$book->save();
$query = BookQuery::create()->filterByTitle('Weirdness')->innerJoinAuthor()->useBookOpinionQuery(null, Criteria::LEFT_JOIN)->leftJoinBookReader()->endUse()->with('Author')->with('BookOpinion')->with('BookReader');
$books = $query->findOne($this->con);
$this->assertEquals(0, count($books->getBookOpinions()));
}