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