本文整理汇总了PHP中Author::setLastName方法的典型用法代码示例。如果您正苦于以下问题:PHP Author::setLastName方法的具体用法?PHP Author::setLastName怎么用?PHP Author::setLastName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Author
的用法示例。
在下文中一共展示了Author::setLastName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testInvalidCharset
public function testInvalidCharset()
{
$this->markTestSkipped();
$db = Propel::getDB(BookPeer::DATABASE_NAME);
if ($db instanceof DBSQLite) {
$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 DBPostgres) {
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: testToStringUsesDefaultStringFormat
public function testToStringUsesDefaultStringFormat()
{
$author = new Author();
$author->setFirstName('John');
$author->setLastName('Doe');
$expected = <<<EOF
Id: null
FirstName: John
LastName: Doe
Email: null
Age: null
EOF;
$this->assertEquals($expected, (string) $author, 'generated __toString() uses default string format and exportTo()');
$publisher = new Publisher();
$publisher->setId(345345);
$publisher->setName('Peguinoo');
$expected = <<<EOF
<?xml version="1.0" encoding="UTF-8"?>
<data>
<Id>345345</Id>
<Name><![CDATA[Peguinoo]]></Name>
</data>
EOF;
$this->assertEquals($expected, (string) $publisher, 'generated __toString() uses default string format and exportTo()');
}
示例3: runAuthorInsertion
function runAuthorInsertion($i)
{
$author = new Author();
$author->setFirstName('John' . $i);
$author->setLastName('Doe' . $i);
$author->save($this->con);
$this->authors[] = $author->getId();
}
示例4: lol
public function lol()
{
$author = new Author();
$author->setFirstName('Jane' . rand(1, 100));
$author->setLastName('Austen' . rand(1, 100));
$author->save();
return $author;
}
示例5: authorInsertion
function authorInsertion($firstName, $lastName)
{
$author = new \Author();
$author->setFirstName($firstName);
$author->setLastName($lastName);
$author->save();
return $author;
}
示例6: testSetLastName
function testSetLastName()
{
//Arrange
$first_name = "J.K.";
$last_name = "Rowling";
$test_author = new Author($first_name, $last_name);
//Act
$test_author->setLastName("Rowling");
$result = $test_author->getLastName();
//Assert
$this->assertEquals("Rowling", $result);
}
示例7: runAuthorInsertion
function runAuthorInsertion($i)
{
$author = new Author();
$author->setFirstName('John' . $i);
$author->setLastName('Doe' . $i);
$this->session->persist($author);
$this->authors[] = $author;
$this->i++;
if ($this->i >= 500) {
$this->commit();
$this->beginTransaction();
}
}
示例8: testFromArray
public function testFromArray()
{
$author = new Author();
$author->setFirstName('Jane');
$author->setLastName('Austen');
$author->save();
$books = array(array('Title' => 'Mansfield Park', 'AuthorId' => $author->getId()), array('Title' => 'Pride And PRejudice', 'AuthorId' => $author->getId()));
$col = new PropelObjectCollection();
$col->setModel('Book');
$col->fromArray($books);
$col->save();
$nbBooks = PropelQuery::from('Book')->count();
$this->assertEquals(6, $nbBooks);
$booksByJane = PropelQuery::from('Book b')->join('b.Author a')->where('a.LastName = ?', 'Austen')->count();
$this->assertEquals(2, $booksByJane);
}
示例9: testSavedObjectCreatesDifferentHashForIdenticalObjects
/**
* Primary key should differ
*/
public function testSavedObjectCreatesDifferentHashForIdenticalObjects()
{
$book1 = new Book();
$book1->setTitle('Foo5');
$book1->setISBN('1234');
$author1 = new Author();
$author1->setFirstName('JAne');
$author1->setLastName('JAne');
$author1->addBook($book1);
$author1->save();
$author2 = new Author();
$author2->setFirstName('JAne');
$author2->setLastName('JAne');
$author2->addBook($book1);
$author2->save();
$this->assertNotEquals($author1->hashCode(), $author2->hashCode());
}
示例10: testSerializeObjectWithCollections
public function testSerializeObjectWithCollections()
{
$book1 = new Book();
$book1->setTitle('Foo5');
$book1->setISBN('1234');
$book2 = new Book();
$book2->setTitle('Foo6');
$book2->setISBN('1234');
$author = new Author();
$author->setFirstName('JAne');
$author->setLastName('JAne');
$author->addBook($book1);
$author->addBook($book2);
$author->save();
$a = clone $author;
$sa = serialize($a);
$author->clearAllReferences();
$this->assertEquals($author, unserialize($sa));
}
示例11: setUp
protected function setUp()
{
parent::setUp();
$publisher = new Publisher();
$publisher->setId(1234);
$publisher->setName('Penguin');
$author = new Author();
$author->setId(5678);
$author->setFirstName('George');
$author->setLastName('Byron');
$book = new Book();
$book->setId(9012);
$book->setTitle('Don Juan');
$book->setISBN('0140422161');
$book->setPrice(12.99);
$book->setAuthor($author);
$book->setPublisher($publisher);
$this->book = $book;
}
示例12: setUp
public function setUp()
{
parent::setUp();
$a = new Author();
$a->setFirstName("Douglas");
$a->setLastName("Adams");
$b1 = new Book();
$b1->setTitle("The Hitchhikers Guide To The Galaxy");
$a->addBook($b1);
$b2 = new Book();
$b2->setTitle("The Restaurant At The End Of The Universe");
$a->addBook($b2);
$a->save();
$this->author = $a;
$this->books = array($b1, $b2);
Propel::enableInstancePooling();
// Clear author instance pool so the object would be fetched from the database
AuthorPeer::clearInstancePool();
}
示例13: Author
$can_save = false;
if ($id > -1 && strlen($first_name) > 0 && strlen($last_name) > 0) {
$can_save = true;
}
if ($can_save) {
$author = new Author();
if ($id > 0) {
$author = new Author($id);
$isNewAuthor = false;
} else {
$author->create(array('first_name' => $first_name, 'last_name' => $last_name));
$isNewAuthor = true;
}
$uploadFileSpecified = isset($_FILES['file']) && isset($_FILES['file']['name']) && !empty($_FILES['file']['name']);
$author->setFirstName($first_name);
$author->setLastName($last_name);
$author->commit();
// Reset types
$types = Input::Get('type', 'array', array());
AuthorAssignedType::ResetAuthorAssignedTypes($author->getId());
foreach ($types as $type) {
$author->setType($type);
}
$author->setSkype(Input::Get('skype'));
$author->setJabber(Input::Get('jabber'));
$author->setAim(Input::Get('aim'));
$author->setEmail(Input::Get('email'));
$authorBiography = array();
$authorBiography['biography'] = Input::Get("txt_biography", "string");
$authorBiography['language'] = Input::Get("lang", "int", 0);
$authorBiography['first_name'] = Input::Get("lang_first_name");
示例14: testNestedTransactionForceRollBack
public function testNestedTransactionForceRollBack()
{
$con = Propel::getConnection(BookPeer::DATABASE_NAME);
$driver = $con->getAttribute(PDO::ATTR_DRIVER_NAME);
// main transaction
$con->beginTransaction();
$a = new Author();
$a->setFirstName('Test');
$a->setLastName('User');
$a->save($con);
$authorId = $a->getId();
// nested transaction
$con->beginTransaction();
$a2 = new Author();
$a2->setFirstName('Test2');
$a2->setLastName('User2');
$a2->save($con);
$authorId2 = $a2->getId();
// force rollback
$con->forceRollback();
$this->assertEquals(0, $con->getNestedTransactionCount(), 'nested transaction is null after nested transaction forced rollback');
$this->assertFalse($con->isInTransaction(), 'PropelPDO is not in transaction after nested transaction force rollback');
AuthorPeer::clearInstancePool();
$at = AuthorPeer::retrieveByPK($authorId);
$this->assertNull($at, "Rolled back transaction is not persisted in database");
$at2 = AuthorPeer::retrieveByPK($authorId2);
$this->assertNull($at2, "Forced Rolled back nested transaction is not persisted in database");
}
示例15: execute
//.........这里部分代码省略.........
}
}
$article->setHideCoverPageAbstract($hideCoverPageAbstract, null);
// Localized
$article->setDiscipline($this->getData('discipline'), null);
// Localized
$article->setSubjectClass($this->getData('subjectClass'), null);
// Localized
$article->setSubject($this->getData('subject'), null);
// Localized
$article->setCoverageGeo($this->getData('coverageGeo'), null);
// Localized
$article->setCoverageChron($this->getData('coverageChron'), null);
// Localized
$article->setCoverageSample($this->getData('coverageSample'), null);
// Localized
$article->setType($this->getData('type'), null);
// Localized
$article->setLanguage($this->getData('language'));
// Localized
$article->setSponsor($this->getData('sponsor'), null);
// Localized
$article->setCitations($this->getData('citations'));
if ($this->isEditor) {
$article->setHideAuthor($this->getData('hideAuthor') ? $this->getData('hideAuthor') : 0);
}
// consider the additional field names from the public identifer plugins
import('classes.plugins.PubIdPluginHelper');
$pubIdPluginHelper = new PubIdPluginHelper();
$pubIdPluginHelper->execute($this, $article);
// Update authors
$authors = $this->getData('authors');
for ($i = 0, $count = count($authors); $i < $count; $i++) {
if ($authors[$i]['authorId'] > 0) {
// Update an existing author
$author =& $authorDao->getAuthor($authors[$i]['authorId'], $article->getId());
$isExistingAuthor = true;
} else {
// Create a new author
if (checkPhpVersion('5.0.0')) {
// *5488* PHP4 Requires explicit instantiation-by-reference
$author = new Author();
} else {
$author =& new Author();
}
$isExistingAuthor = false;
}
if ($author != null) {
$author->setSubmissionId($article->getId());
$author->setFirstName($authors[$i]['firstName']);
$author->setMiddleName($authors[$i]['middleName']);
$author->setLastName($authors[$i]['lastName']);
$author->setAffiliation($authors[$i]['affiliation'], null);
// Localized
$author->setCountry($authors[$i]['country']);
$author->setEmail($authors[$i]['email']);
$author->setData('orcid', $authors[$i]['orcid']);
$author->setUrl($authors[$i]['url']);
if (array_key_exists('competingInterests', $authors[$i])) {
$author->setCompetingInterests($authors[$i]['competingInterests'], null);
// Localized
}
$author->setBiography($authors[$i]['biography'], null);
// Localized
$author->setPrimaryContact($this->getData('primaryContact') == $i ? 1 : 0);
$author->setSequence($authors[$i]['seq']);
HookRegistry::call('Submission::Form::MetadataForm::Execute', array(&$author, &$authors[$i]));
if ($isExistingAuthor) {
$authorDao->updateAuthor($author);
} else {
$authorDao->insertAuthor($author);
}
unset($author);
}
}
// Remove deleted authors
$deletedAuthors = preg_split('/:/', $this->getData('deletedAuthors'), -1, PREG_SPLIT_NO_EMPTY);
for ($i = 0, $count = count($deletedAuthors); $i < $count; $i++) {
$authorDao->deleteAuthorById($deletedAuthors[$i], $article->getId());
}
if ($this->isEditor) {
$article->setCopyrightHolder($this->getData('copyrightHolder'), null);
$article->setCopyrightYear($this->getData('copyrightYear'));
$article->setLicenseURL($this->getData('licenseURL'));
}
parent::execute();
// Save the article
$articleDao->updateArticle($article);
// Update search index
import('classes.search.ArticleSearchIndex');
$articleSearchIndex = new ArticleSearchIndex();
$articleSearchIndex->articleMetadataChanged($article);
$articleSearchIndex->articleChangesFinished();
// Update references list if it changed.
$rawCitationList = $article->getCitations();
if ($previousRawCitationList != $rawCitationList) {
$citationDao->importCitations($request, ASSOC_TYPE_ARTICLE, $article->getId(), $rawCitationList);
}
return $article->getId();
}