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


PHP Book::getPublisher方法代碼示例

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


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

示例1: testObjectInstances_Fkeys

 /**
  *
  */
 public function testObjectInstances_Fkeys()
 {
     // Establish a relationship between one employee and account
     // and then change the employee_id and ensure that the account
     // is not pulling the old employee.
     $pub1 = new Publisher();
     $pub1->setName('Publisher 1');
     $pub1->save();
     $pub2 = new Publisher();
     $pub2->setName('Publisher 2');
     $pub2->save();
     $book = new Book();
     $book->setTitle("Book Title");
     $book->setISBN("1234");
     $book->setPublisher($pub1);
     $book->save();
     $this->assertSame($pub1, $book->getPublisher());
     // now change values behind the scenes
     $con = Propel::getServiceContainer()->getConnection(BookstoreEmployeeAccountTableMap::DATABASE_NAME);
     $con->exec("UPDATE " . BookTableMap::TABLE_NAME . " SET " . " publisher_id = " . $pub2->getId() . " WHERE id = " . $book->getId());
     $book2 = BookQuery::create()->findPk($book->getId());
     $this->assertSame($book, $book2, "Expected same book object instance");
     $this->assertEquals($pub1->getId(), $book->getPublisherId(), "Expected book to have OLD publisher id before reload()");
     $book->reload();
     $this->assertEquals($pub2->getId(), $book->getPublisherId(), "Expected book to have new publisher id");
     $this->assertSame($pub2, $book->getPublisher(), "Expected book to have new publisher object associated.");
     // Now let's set it back, just to be double sure ...
     $con->exec("UPDATE " . BookTableMap::TABLE_NAME . " SET " . " publisher_id = " . $pub1->getId() . " WHERE id = " . $book->getId());
     $book->reload();
     $this->assertEquals($pub1->getId(), $book->getPublisherId(), "Expected book to have old publisher id (again).");
     $this->assertSame($pub1, $book->getPublisher(), "Expected book to have old publisher object associated (again).");
 }
開發者ID:robin850,項目名稱:Propel2,代碼行數:35,代碼來源:GeneratedObjectTest.php


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