當前位置: 首頁>>代碼示例>>PHP>>正文


PHP BookPeer::retrieveByPk方法代碼示例

本文整理匯總了PHP中BookPeer::retrieveByPk方法的典型用法代碼示例。如果您正苦於以下問題:PHP BookPeer::retrieveByPk方法的具體用法?PHP BookPeer::retrieveByPk怎麽用?PHP BookPeer::retrieveByPk使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在BookPeer的用法示例。


在下文中一共展示了BookPeer::retrieveByPk方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testScenario


//.........這裏部分代碼省略.........
         $r2->setRecommended(false);
         $r2->setReviewDate(time());
         $r2->save();
         $r2_id = $r2->getId();
         $this->assertTrue(true, 'Save Review records');
     } catch (Exception $e) {
         $this->fail('Save Review records');
     }
     // Perform a "complex" search
     // --------------------------
     $crit = new Criteria();
     $crit->add(BookPeer::TITLE, 'Harry%', Criteria::LIKE);
     $results = BookPeer::doSelect($crit);
     $this->assertEquals(1, count($results));
     $crit2 = new Criteria();
     $crit2->add(BookPeer::ISBN, array("0380977427", "0140422161"), Criteria::IN);
     $results = BookPeer::doSelect($crit2);
     $this->assertEquals(2, count($results));
     // Perform a "limit" search
     // ------------------------
     $crit = new Criteria();
     $crit->setLimit(2);
     $crit->setOffset(1);
     $crit->addAscendingOrderByColumn(BookPeer::TITLE);
     $results = BookPeer::doSelect($crit);
     $this->assertEquals(2, count($results));
     // we ordered on book title, so we expect to get
     $this->assertEquals("Harry Potter and the Order of the Phoenix", $results[0]->getTitle());
     $this->assertEquals("Quicksilver", $results[1]->getTitle());
     // Perform a lookup & update!
     // --------------------------
     // Updating just-created book title
     // First finding book by PK (=$qs_id) ....
     $qs_lookup = BookPeer::retrieveByPk($qs_id);
     $this->assertNotNull($qs_lookup, 'just-created book can be found by pk');
     $new_title = "Quicksilver (" . crc32(uniqid(rand())) . ")";
     // Attempting to update found object
     $qs_lookup->setTitle($new_title);
     $qs_lookup->save();
     // Making sure object was correctly updated: ";
     $qs_lookup2 = BookPeer::retrieveByPk($qs_id);
     $this->assertEquals($new_title, $qs_lookup2->getTitle());
     // Test some basic DATE / TIME stuff
     // ---------------------------------
     // that's the control timestamp.
     $control = strtotime('2004-02-29 00:00:00');
     // should be two in the db
     $r = ReviewPeer::doSelectOne(new Criteria());
     $r_id = $r->getId();
     $r->setReviewDate($control);
     $r->save();
     $r2 = ReviewPeer::retrieveByPk($r_id);
     $this->assertEquals(new Datetime('2004-02-29 00:00:00'), $r2->getReviewDate(null), 'ability to fetch DateTime');
     $this->assertEquals($control, $r2->getReviewDate('U'), 'ability to fetch native unix timestamp');
     $this->assertEquals('2-29-2004', $r2->getReviewDate('n-j-Y'), 'ability to use date() formatter');
     // Handle BLOB/CLOB Columns
     // ------------------------
     $blob_path = dirname(__FILE__) . '/../../etc/lob/tin_drum.gif';
     $blob2_path = dirname(__FILE__) . '/../../etc/lob/propel.gif';
     $clob_path = dirname(__FILE__) . '/../../etc/lob/tin_drum.txt';
     $m1 = new Media();
     $m1->setBook($phoenix);
     $m1->setCoverImage(file_get_contents($blob_path));
     $m1->setExcerpt(file_get_contents($clob_path));
     $m1->save();
     $m1_id = $m1->getId();
開發者ID:dracony,項目名稱:forked-php-orm-benchmark,代碼行數:67,代碼來源:BookstoreTest.php

示例2: getBook

 /**
  * Get the associated Book object
  *
  * @param      PropelPDO Optional Connection object.
  * @return     Book The associated Book object.
  * @throws     PropelException
  */
 public function getBook(PropelPDO $con = null)
 {
     if ($this->aBook === null && $this->book_id !== null) {
         $this->aBook = BookPeer::retrieveByPk($this->book_id);
         /* The following can be used additionally to
         		   guarantee the related object contains a reference
         		   to this object.  This level of coupling may, however, be
         		   undesirable since it could result in an only partially populated collection
         		   in the referenced object.
         		   $this->aBook->addArticles($this);
         		 */
     }
     return $this->aBook;
 }
開發者ID:omarcl,項目名稱:training-spot,代碼行數:21,代碼來源:BaseArticle.php

示例3: testDoDeleteAllInstancePool

 /**
  * Test the state of the instance pool after a doDeleteAll() call.
  */
 public function testDoDeleteAllInstancePool()
 {
     $review = ReviewPeer::doSelectOne(new Criteria());
     $book = $review->getBook();
     BookPeer::doDeleteAll();
     $this->assertNull(BookPeer::retrieveByPk($book->getId()), 'doDeleteAll invalidates instance pool');
     $this->assertNull(ReviewPeer::retrieveByPk($review->getId()), 'doDeleteAll invalidates instance pool of releted tables with ON DELETE CASCADE');
 }
開發者ID:ketheriel,項目名稱:ETVA,代碼行數:11,代碼來源:GeneratedPeerDoDeleteTest.php

示例4: boolTest

    print "Making sure BookClubList 1 has 2 BookListRels: ";
    print boolTest($relCount == 2);
    $relCount = $blc2->countBookListRels();
    print "Making sure BookClubList 2 has 1 BookListRel: ";
    print boolTest($relCount == 1);
} catch (Exception $e) {
    die("Error doing many-to-many relationships tests: " . $e->__toString());
}
// Cleanup (tests DELETE)
// ----------------------
try {
    print "\nRemoving books that were just created\n";
    print "-------------------------------------\n\n";
    print "First finding book by PK (={$phoenix_id}) .... ";
    try {
        $hp = BookPeer::retrieveByPk($phoenix_id);
    } catch (Exception $e) {
        print "ERROR!\n";
        die("Error retrieving by pk: " . $e->__toString());
    }
    if ($hp) {
        print "FOUND!\n";
    } else {
        print "NOT FOUND :(\n";
        die("Couldn't find just-created book: book_id = {$phoenix_id}");
    }
    print "Attempting to delete [multi-table] by found pk: ";
    $c = new Criteria();
    $c->add(BookPeer::ID, $hp->getId());
    // The only way for cascading to work currently
    // is to specify the author_id and publisher_id (i.e. the fkeys
開發者ID:yasirgit,項目名稱:afids,代碼行數:31,代碼來源:bookstore-test.php

示例5: testSpeed


//.........這裏部分代碼省略.........
     // 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);
     $crit->addAscendingOrderByColumn(BookPeer::TITLE);
     $results = BookPeer::doSelect($crit);
     // Perform a lookup & update!
     // --------------------------
     $qs_lookup = BookPeer::retrieveByPk($qs_id);
     $new_title = "Quicksilver (" . crc32(uniqid(rand())) . ")";
     $qs_lookup->setTitle($new_title);
     $qs_lookup->save();
     $qs_lookup2 = BookPeer::retrieveByPk($qs_id);
     // Test some basic DATE / TIME stuff
     // ---------------------------------
     // that's the control timestamp.
     $control = strtotime('2004-02-29 00:00:00');
     // should be two in the db
     $r = ReviewPeer::doSelectOne(new Criteria());
     $r_id = $r->getId();
     $r->setReviewDate($control);
     $r->save();
     $r2 = ReviewPeer::retrieveByPk($r_id);
     // Testing the DATE/TIME columns
     // -----------------------------
     // that's the control timestamp.
     $control = strtotime('2004-02-29 00:00:00');
     // should be two in the db
     $r = ReviewPeer::doSelectOne(new Criteria());
     $r_id = $r->getId();
     $r->setReviewDate($control);
     $r->save();
     $r2 = ReviewPeer::retrieveByPk($r_id);
     // Testing the column validators
     // -----------------------------
     $bk1 = new Book();
     $bk1->setTitle("12345");
     // min length is 10
     $ret = $bk1->validate();
     // Unique validator
     $bk2 = new Book();
開發者ID:dracony,項目名稱:forked-php-orm-benchmark,代碼行數:67,代碼來源:speed.php


注:本文中的BookPeer::retrieveByPk方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。