本文整理汇总了PHP中Propel\Tests\Bookstore\Author::reload方法的典型用法代码示例。如果您正苦于以下问题:PHP Author::reload方法的具体用法?PHP Author::reload怎么用?PHP Author::reload使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Propel\Tests\Bookstore\Author
的用法示例。
在下文中一共展示了Author::reload方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testInvalidCharset
public function testInvalidCharset()
{
$this->markTestSkipped('Skipped because of weird behavior on some platforms');
$db = Propel::getServiceContainer()->getAdapter(BookPeer::DATABASE_NAME);
if ($db instanceof SqliteAdapter) {
$this->markTestSkipped();
}
$a = new Author();
$a->setFirstName("Б.");
$a->setLastName("АКУНИН");
$a->save();
$authorNameWindows1251 = iconv("utf-8", "windows-1251", $a->getLastName());
$a->setLastName($authorNameWindows1251);
// Different databases seem to handle invalid data differently (no surprise, I guess...)
if ($db instanceof PgsqlAdapter) {
try {
$a->save();
$this->fail("Expected an exception when saving non-UTF8 data to database.");
} catch (Exception $x) {
print $x;
}
} else {
// No exception is thrown by MySQL ... (others need to be tested still)
$a->save();
$a->reload();
$this->assertEquals("", $a->getLastName(), "Expected last_name to be empty (after inserting invalid charset data)");
}
}
示例2: testSymfonyFormManyToOne
public function testSymfonyFormManyToOne()
{
BookQuery::create()->deleteAll();
AuthorQuery::create()->deleteAll();
// We create a simple book and a simple Author and simply link them to each other before reloading them
$book = new Book();
$book->setISBN('012345');
$book->setTitle('Propel Book');
$author = new Author();
$author->setFirstName('François');
$author->setLastName('Z');
$author->addBook($book);
$author->save();
$book->save();
$author->reload(true);
$book->reload(true);
// Symfony is cloning the book object in a ManyToOne form with by_reference = false
$book2 = clone $book;
$author->removeBook($book);
$author->addBook($book2);
$author->save();
$author->reload(true);
$books = $author->getBooks();
$this->assertCount(1, $books);
}