本文整理汇总了PHP中Review::setReviewedBy方法的典型用法代码示例。如果您正苦于以下问题:PHP Review::setReviewedBy方法的具体用法?PHP Review::setReviewedBy怎么用?PHP Review::setReviewedBy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Review
的用法示例。
在下文中一共展示了Review::setReviewedBy方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testScenarioUsingQuery
public function testScenarioUsingQuery()
{
// Add publisher records
// ---------------------
try {
$scholastic = new Publisher();
$scholastic->setName("Scholastic");
// do not save, will do later to test cascade
$morrow = new Publisher();
$morrow->setName("William Morrow");
$morrow->save();
$morrow_id = $morrow->getId();
$penguin = new Publisher();
$penguin->setName("Penguin");
$penguin->save();
$penguin_id = $penguin->getId();
$vintage = new Publisher();
$vintage->setName("Vintage");
$vintage->save();
$vintage_id = $vintage->getId();
$this->assertTrue(true, 'Save Publisher records');
} catch (Exception $e) {
$this->fail('Save publisher records');
}
// Add author records
// ------------------
try {
$rowling = new Author();
$rowling->setFirstName("J.K.");
$rowling->setLastName("Rowling");
// do not save, will do later to test cascade
$stephenson = new Author();
$stephenson->setFirstName("Neal");
$stephenson->setLastName("Stephenson");
$stephenson->save();
$stephenson_id = $stephenson->getId();
$byron = new Author();
$byron->setFirstName("George");
$byron->setLastName("Byron");
$byron->save();
$byron_id = $byron->getId();
$grass = new Author();
$grass->setFirstName("Gunter");
$grass->setLastName("Grass");
$grass->save();
$grass_id = $grass->getId();
$this->assertTrue(true, 'Save Author records');
} catch (Exception $e) {
$this->fail('Save Author records');
}
// Add book records
// ----------------
try {
$phoenix = new Book();
$phoenix->setTitle("Harry Potter and the Order of the Phoenix");
$phoenix->setISBN("043935806X");
$phoenix->setAuthor($rowling);
$phoenix->setPublisher($scholastic);
$phoenix->save();
$phoenix_id = $phoenix->getId();
$this->assertFalse($rowling->isNew(), 'saving book also saves related author');
$this->assertFalse($scholastic->isNew(), 'saving book also saves related publisher');
$qs = new Book();
$qs->setISBN("0380977427");
$qs->setTitle("Quicksilver");
$qs->setAuthor($stephenson);
$qs->setPublisher($morrow);
$qs->save();
$qs_id = $qs->getId();
$dj = new Book();
$dj->setISBN("0140422161");
$dj->setTitle("Don Juan");
$dj->setAuthor($byron);
$dj->setPublisher($penguin);
$dj->save();
$dj_id = $qs->getId();
$td = new Book();
$td->setISBN("067972575X");
$td->setTitle("The Tin Drum");
$td->setAuthor($grass);
$td->setPublisher($vintage);
$td->save();
$td_id = $td->getId();
$this->assertTrue(true, 'Save Book records');
} catch (Exception $e) {
$this->fail('Save Author records');
}
// Add review records
// ------------------
try {
$r1 = new Review();
$r1->setBook($phoenix);
$r1->setReviewedBy("Washington Post");
$r1->setRecommended(true);
$r1->setReviewDate(time());
$r1->save();
$r1_id = $r1->getId();
$r2 = new Review();
$r2->setBook($phoenix);
$r2->setReviewedBy("New York Times");
//.........这里部分代码省略.........
示例2: testFindWithLeftJoinWithManyToOneAndNullObject
public function testFindWithLeftJoinWithManyToOneAndNullObject()
{
BookPeer::clearInstancePool();
AuthorPeer::clearInstancePool();
ReviewPeer::clearInstancePool();
$review = new Review();
$review->setReviewedBy('Toto');
$review->setRecommended('0');
$review->save($this->con);
$c = new ModelCriteria('bookstore', 'Review');
$c->setFormatter(ModelCriteria::FORMAT_ON_DEMAND);
$c->leftJoinWith('Review.Book');
$c->leftJoinWith('Book.Author');
// should not raise a notice
$reviews = $c->find($this->con);
$this->assertTrue(true);
}
示例3: testCountRefFk
public function testCountRefFk()
{
$book = new Book();
$book->setTitle("Test Book");
$book->setISBN("TT-EE-SS-TT");
$num = 5;
for ($i = 2; $i < $num + 2; $i++) {
$r = new Review();
$r->setReviewedBy('Hans ' . $num);
$dt = new DateTime("now");
$dt->modify("-" . $i . " weeks");
$r->setReviewDate($dt);
$r->setRecommended($i % 2 == 0);
$book->addReview($r);
}
$this->assertEquals($num, $book->countReviews(), "Expected countReviews to return {$num}");
$this->assertEquals($num, count($book->getReviews()), "Expected getReviews to return {$num} reviews");
$book->save();
BookPeer::clearInstancePool();
ReviewPeer::clearInstancePool();
$book = BookPeer::retrieveByPK($book->getId());
$this->assertEquals($num, $book->countReviews(), "Expected countReviews() to return {$num} (after save)");
$this->assertEquals($num, count($book->getReviews()), "Expected getReviews() to return {$num} (after save)");
// Now set different criteria and expect different results
$c = new Criteria();
$c->add(ReviewPeer::RECOMMENDED, false);
$this->assertEquals(floor($num / 2), $book->countReviews($c), "Expected " . floor($num / 2) . " results from countReviews(recomm=false)");
// Change Criteria, run again -- expect different.
$c = new Criteria();
$c->add(ReviewPeer::RECOMMENDED, true);
$this->assertEquals(ceil($num / 2), count($book->getReviews($c)), "Expected " . ceil($num / 2) . " results from getReviews(recomm=true)");
$this->assertEquals($num, $book->countReviews(), "Expected countReviews to return {$num} with new empty Criteria");
}
示例4: catch
$td->setAuthor($grass);
$td->setPublisher($vintage);
$td->save();
$td_id = $td->getId();
print "Added book \"The Tin Drum\" [id = {$dj_id}].\n";
} catch (Exception $e) {
die("Error saving book: " . $e->__toString());
}
// Add review records
// ------------------
try {
print "\nAdding some book reviews to the list\n";
print "------------------------------------\n\n";
$r1 = new Review();
$r1->setBook($phoenix);
$r1->setReviewedBy("Washington Post");
$r1->setRecommended(true);
$r1->setReviewDate(time());
$r1->save();
$r1_id = $r1->getId();
print "Added Washington Post book review [id = {$r1_id}].\n";
$r2 = new Review();
$r2->setBook($phoenix);
$r2->setReviewedBy("New York Times");
$r2->setRecommended(false);
$r2->setReviewDate(time());
$r2->save();
$r2_id = $r2->getId();
print "Added New York Times book review [id = {$r2_id}].\n";
} catch (Exception $e) {
die("Error saving book review: " . $e->__toString());
示例5: testClearRefFk
/**
* Test the clearing of related object collection.
* @link http://www.propelorm.org/ticket/529
*/
public function testClearRefFk()
{
BookstoreDataPopulator::populate();
$book = new Book();
$book->setISBN("Foo-bar-baz");
$book->setTitle("The book title");
// No save ...
$r = new Review();
$r->setReviewedBy('Me');
$r->setReviewDate(new DateTime("now"));
$book->addReview($r);
// No save (yet) ...
$this->assertEquals(1, count($book->getReviews()));
$book->clearReviews();
$this->assertEquals(0, count($book->getReviews()));
}
示例6: testSpeed
public function testSpeed()
{
// 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();
$morrow_id = $morrow->getId();
$penguin = new Publisher();
$penguin->setName("Penguin");
$penguin->save();
$penguin_id = $penguin->getId();
$vintage = new Publisher();
$vintage->setName("Vintage");
$vintage->save();
$vintage_id = $vintage->getId();
// Add author records
// ------------------
$rowling = new Author();
$rowling->setFirstName("J.K.");
$rowling->setLastName("Rowling");
// no save()
$stephenson = new Author();
$stephenson->setFirstName("Neal");
$stephenson->setLastName("Stephenson");
$stephenson->save();
$stephenson_id = $stephenson->getId();
$byron = new Author();
$byron->setFirstName("George");
$byron->setLastName("Byron");
$byron->save();
$byron_id = $byron->getId();
$grass = new Author();
$grass->setFirstName("Gunter");
$grass->setLastName("Grass");
$grass->save();
$grass_id = $grass->getId();
// Add book records
// ----------------
$phoenix = new Book();
$phoenix->setTitle("Harry Potter and the Order of the Phoenix");
$phoenix->setISBN("043935806X");
// cascading save (Harry Potter)
$phoenix->setAuthor($rowling);
$phoenix->setPublisher($scholastic);
$phoenix->save();
$phoenix_id = $phoenix->getId();
$qs = new Book();
$qs->setISBN("0380977427");
$qs->setTitle("Quicksilver");
$qs->setAuthor($stephenson);
$qs->setPublisher($morrow);
$qs->save();
$qs_id = $qs->getId();
$dj = new Book();
$dj->setISBN("0140422161");
$dj->setTitle("Don Juan");
$dj->setAuthor($byron);
$dj->setPublisher($penguin);
$dj->save();
$dj_id = $qs->getId();
$td = new Book();
$td->setISBN("067972575X");
$td->setTitle("The Tin Drum");
$td->setAuthor($grass);
$td->setPublisher($vintage);
$td->save();
$td_id = $td->getId();
// Add review records
// ------------------
$r1 = new Review();
$r1->setBook($phoenix);
$r1->setReviewedBy("Washington Post");
$r1->setRecommended(true);
$r1->setReviewDate(time());
$r1->save();
$r1_id = $r1->getId();
$r2 = new Review();
$r2->setBook($phoenix);
$r2->setReviewedBy("New York Times");
$r2->setRecommended(false);
$r2->setReviewDate(time());
$r2->save();
$r2_id = $r2->getId();
// Perform a "complex" search
// --------------------------
$crit = new Criteria();
$crit->add(BookPeer::TITLE, 'Harry%', Criteria::LIKE);
$results = BookPeer::doSelect($crit);
$crit2 = new Criteria();
$crit2->add(BookPeer::ISBN, array("0380977427", "0140422161"), Criteria::IN);
$results = BookPeer::doSelect($crit2);
// Perform a "limit" search
// ------------------------
$crit = new Criteria();
$crit->setLimit(2);
$crit->setOffset(1);
//.........这里部分代码省略.........
示例7: 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
// ---------------------
//.........这里部分代码省略.........
示例8: testTypeSensitive
/**
* Test the type sensitivity of the resturning columns.
*
*/
public function testTypeSensitive()
{
BookstoreDataPopulator::populate();
$book = BookPeer::doSelectOne(new Criteria());
$r = new Review();
$r->setReviewedBy("testTypeSensitive Tester");
$r->setReviewDate(time());
$r->setBook($book);
$r->setRecommended(true);
$r->save();
$id = $r->getId();
unset($r);
// clear the instance cache to force reload from database.
ReviewPeer::clearInstancePool();
BookPeer::clearInstancePool();
// reload and verify that the types are the same
$r2 = ReviewPeer::retrieveByPK($id);
$this->assertInternalType('integer', $r2->getId(), "Expected getId() to return an integer.");
$this->assertInternalType('string', $r2->getReviewedBy(), "Expected getReviewedBy() to return a string.");
$this->assertInternalType('boolean', $r2->getRecommended(), "Expected getRecommended() to return a boolean.");
$this->assertInstanceOf('Book', $r2->getBook(), "Expected getBook() to return a Book.");
$this->assertInternalType('float', $r2->getBook()->getPrice(), "Expected Book->getPrice() to return a float.");
$this->assertInstanceOf('DateTime', $r2->getReviewDate(null), "Expected Book->getReviewDate() to return a DateTime.");
}