当前位置: 首页>>代码示例>>PHP>>正文


PHP Book::getId方法代码示例

本文整理汇总了PHP中Propel\Tests\Bookstore\Book::getId方法的典型用法代码示例。如果您正苦于以下问题:PHP Book::getId方法的具体用法?PHP Book::getId怎么用?PHP Book::getId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Propel\Tests\Bookstore\Book的用法示例。


在下文中一共展示了Book::getId方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setUp

 protected function setUp()
 {
     parent::setUp();
     BookstoreDataPopulator::populate();
     $cr = new Criteria();
     $cr->add(AuthorPeer::LAST_NAME, "Rowling");
     $cr->add(AuthorPeer::FIRST_NAME, "J.K.");
     $rowling = AuthorPeer::doSelectOne($cr);
     $this->authorId = $rowling->getId();
     $book = new Book();
     $book->setTitle("Harry Potter and the Philosopher's Stone");
     $book->setISBN("1234");
     $book->setAuthor($rowling);
     $book->save();
     $this->books[] = $book->getId();
     $book = new Book();
     $book->setTitle("Harry Potter and the Chamber of Secrets");
     $book->setISBN("1234");
     $book->setAuthor($rowling);
     $book->save();
     $this->books[] = $book->getId();
     $book = new Book();
     $book->setTitle("Harry Potter and the Prisoner of Azkaban");
     $book->setISBN("1234");
     $book->setAuthor($rowling);
     $book->save();
     $this->books[] = $book->getId();
     $book = new Book();
     $book->setTitle("Harry Potter and the Goblet of Fire");
     $book->setISBN("1234");
     $book->setAuthor($rowling);
     $book->save();
     $this->books[] = $book->getId();
     $book = new Book();
     $book->setTitle("Harry Potter and the Half-Blood Prince");
     $book->setISBN("1234");
     $book->setAuthor($rowling);
     $book->save();
     $this->books[] = $book->getId();
     $book = new Book();
     $book->setTitle("Harry Potter and the Deathly Hallows");
     $book->setISBN("1234");
     $book->setAuthor($rowling);
     $book->save();
     $this->books[] = $book->getId();
 }
开发者ID:RafalFilipek,项目名称:Propel2,代码行数:46,代码来源:PropelPagerTest.php

示例2: 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");
//.........这里部分代码省略.........
开发者ID:norfil,项目名称:Propel2,代码行数:101,代码来源:BookstoreTest.php

示例3: testFindPkDoesNotCallPreSelectWhenUsingInstancePool

 public function testFindPkDoesNotCallPreSelectWhenUsingInstancePool()
 {
     $b = new Book();
     $b->setTitle('foo');
     $b->setISBN('FA404');
     $b->save();
     $q = new mySecondBookQuery();
     $this->assertFalse($q::$preSelectWasCalled);
     $q->findPk($b->getId());
     $this->assertFalse($q::$preSelectWasCalled);
 }
开发者ID:kalaspuffar,项目名称:php-orm-benchmark,代码行数:11,代码来源:QueryBuilderTest.php

示例4: testSaveCanInsertNonEmptyObjects

 public function testSaveCanInsertNonEmptyObjects()
 {
     $b = new Book();
     $b->setTitle('foo');
     $b->setISBN('FA404');
     $b->save();
     $this->assertFalse($b->isNew());
     $this->assertNotNull($b->getId());
 }
开发者ID:robin850,项目名称:Propel2,代码行数:9,代码来源:GeneratedObjectTest.php

示例5: populate

 public static function populate($con = null)
 {
     if ($con === null) {
         $con = Propel::getServiceContainer()->getConnection(BookTableMap::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::getServiceContainer()->getAdapter()) != "OracleAdapter") {
         $m1->setExcerpt(file_get_contents($clob_path));
     }
     $m1->save($con);
     // Add book list records
     // ---------------------
//.........这里部分代码省略.........
开发者ID:kalaspuffar,项目名称:php-orm-benchmark,代码行数:101,代码来源:BookstoreDataPopulator.php

示例6: testFindPkComplexAddsObjectToInstancePool

 public function testFindPkComplexAddsObjectToInstancePool()
 {
     $b = new Book();
     $b->setTitle('foo');
     $b->setISBN('FA404');
     $b->save($this->con);
     BookTableMap::clearInstancePool();
     BookQuery::create('b')->findPk($b->getId(), $this->con);
     $count = $this->con->getQueryCount();
     $book = BookQuery::create()->findPk($b->getId(), $this->con);
     $this->assertEquals($b, $book);
     $this->assertEquals($count, $this->con->getQueryCount());
 }
开发者ID:naldz,项目名称:cyberden,代码行数:13,代码来源:QueryBuilderTest.php

示例7: createBookWithId

 /**
  * @see testDoDeleteCompositePK()
  */
 private function createBookWithId($id)
 {
     $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME);
     $b = BookQuery::create()->findPk($id);
     if (!$b) {
         $b = new Book();
         $b->setTitle("Book{$id}")->setISBN("BookISBN{$id}")->save();
         $b1Id = $b->getId();
         $sql = "UPDATE " . BookTableMap::TABLE_NAME . " SET id = ? WHERE id = ?";
         $stmt = $con->prepare($sql);
         $stmt->bindValue(1, $id);
         $stmt->bindValue(2, $b1Id);
         $stmt->execute();
     }
 }
开发者ID:kalaspuffar,项目名称:php-orm-benchmark,代码行数:18,代码来源:GeneratedQueryDoDeleteTest.php

示例8: testMultiColFk

 /**
  * Testing foreign keys with multiple referrer columns.
  * @link       http://propel.phpdb.org/trac/ticket/606
  */
 public function testMultiColFk()
 {
     $con = Propel::getServiceContainer()->getConnection(BookPeer::DATABASE_NAME);
     ReaderFavoritePeer::doDeleteAll();
     $b1 = new Book();
     $b1->setTitle("Book1");
     $b1->setISBN("ISBN-1");
     $b1->save();
     $r1 = new BookReader();
     $r1->setName("Me");
     $r1->save();
     $bo1 = new BookOpinion();
     $bo1->setBookId($b1->getId());
     $bo1->setReaderId($r1->getId());
     $bo1->setRating(9);
     $bo1->setRecommendToFriend(true);
     $bo1->save();
     $rf1 = new ReaderFavorite();
     $rf1->setReaderId($r1->getId());
     $rf1->setBookId($b1->getId());
     $rf1->save();
     $c = new Criteria(ReaderFavoritePeer::DATABASE_NAME);
     $c->add(ReaderFavoritePeer::BOOK_ID, $b1->getId());
     $c->add(ReaderFavoritePeer::READER_ID, $r1->getId());
     $results = ReaderFavoritePeer::doSelectJoinBookOpinion($c);
     $this->assertEquals(1, count($results), "Expected 1 result");
 }
开发者ID:rouffj,项目名称:Propel2,代码行数:31,代码来源:GeneratedPeerDoSelectTest.php


注:本文中的Propel\Tests\Bookstore\Book::getId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。