本文整理匯總了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).");
}