当前位置: 首页>>代码示例>>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;未经允许,请勿转载。