本文整理汇总了PHP中Publisher::setName方法的典型用法代码示例。如果您正苦于以下问题:PHP Publisher::setName方法的具体用法?PHP Publisher::setName怎么用?PHP Publisher::setName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Publisher
的用法示例。
在下文中一共展示了Publisher::setName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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()');
}
示例2: 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;
}
示例3: testUtf8
public function testUtf8()
{
$db = Propel::getDB(BookPeer::DATABASE_NAME);
$title = "Смерть на брудершафт. Младенец и черт";
// 1234567890123456789012345678901234567
// 1 2 3
$a = new Author();
$a->setFirstName("Б.");
$a->setLastName("АКУНИН");
$p = new Publisher();
$p->setName("Детектив российский, остросюжетная проза");
$b = new Book();
$b->setTitle($title);
$b->setISBN("B-59246");
$b->setAuthor($a);
$b->setPublisher($p);
$b->save();
$b->reload();
$this->assertEquals(37, iconv_strlen($b->getTitle(), 'utf-8'), "Expected 37 characters (not bytes) in title.");
$this->assertTrue(strlen($b->getTitle()) > iconv_strlen($b->getTitle(), 'utf-8'), "Expected more bytes than characters in title.");
}
示例4: testScenarioUsingQuery
public function testScenarioUsingQuery()
{
// Add publisher records
// ---------------------
try {
$scholastic = new Publisher();
$scholastic->setName("Scholastic");
// do not save, will do later to test cascade
$morrow = new Publisher();
$morrow->setName("William Morrow");
$morrow->save();
$morrow_id = $morrow->getId();
$penguin = new Publisher();
$penguin->setName("Penguin");
$penguin->save();
$penguin_id = $penguin->getId();
$vintage = new Publisher();
$vintage->setName("Vintage");
$vintage->save();
$vintage_id = $vintage->getId();
$this->assertTrue(true, 'Save Publisher records');
} catch (Exception $e) {
$this->fail('Save publisher records');
}
// Add author records
// ------------------
try {
$rowling = new Author();
$rowling->setFirstName("J.K.");
$rowling->setLastName("Rowling");
// do not save, will do later to test cascade
$stephenson = new Author();
$stephenson->setFirstName("Neal");
$stephenson->setLastName("Stephenson");
$stephenson->save();
$stephenson_id = $stephenson->getId();
$byron = new Author();
$byron->setFirstName("George");
$byron->setLastName("Byron");
$byron->save();
$byron_id = $byron->getId();
$grass = new Author();
$grass->setFirstName("Gunter");
$grass->setLastName("Grass");
$grass->save();
$grass_id = $grass->getId();
$this->assertTrue(true, 'Save Author records');
} catch (Exception $e) {
$this->fail('Save Author records');
}
// Add book records
// ----------------
try {
$phoenix = new Book();
$phoenix->setTitle("Harry Potter and the Order of the Phoenix");
$phoenix->setISBN("043935806X");
$phoenix->setAuthor($rowling);
$phoenix->setPublisher($scholastic);
$phoenix->save();
$phoenix_id = $phoenix->getId();
$this->assertFalse($rowling->isNew(), 'saving book also saves related author');
$this->assertFalse($scholastic->isNew(), 'saving book also saves related publisher');
$qs = new Book();
$qs->setISBN("0380977427");
$qs->setTitle("Quicksilver");
$qs->setAuthor($stephenson);
$qs->setPublisher($morrow);
$qs->save();
$qs_id = $qs->getId();
$dj = new Book();
$dj->setISBN("0140422161");
$dj->setTitle("Don Juan");
$dj->setAuthor($byron);
$dj->setPublisher($penguin);
$dj->save();
$dj_id = $qs->getId();
$td = new Book();
$td->setISBN("067972575X");
$td->setTitle("The Tin Drum");
$td->setAuthor($grass);
$td->setPublisher($vintage);
$td->save();
$td_id = $td->getId();
$this->assertTrue(true, 'Save Book records');
} catch (Exception $e) {
$this->fail('Save Author records');
}
// Add review records
// ------------------
try {
$r1 = new Review();
$r1->setBook($phoenix);
$r1->setReviewedBy("Washington Post");
$r1->setRecommended(true);
$r1->setReviewDate(time());
$r1->save();
$r1_id = $r1->getId();
$r2 = new Review();
$r2->setBook($phoenix);
$r2->setReviewedBy("New York Times");
//.........这里部分代码省略.........
示例5: testIsModifiedIsTrueAfterSetToDefaultValueOnModifiedObject
public function testIsModifiedIsTrueAfterSetToDefaultValueOnModifiedObject()
{
$p = new Publisher();
$p->setName('Puffin Books');
$p->resetModified();
$p->setName('Penguin');
// default column value
$this->assertTrue($p->isModified());
}
示例6: Publisher
$scholastic = new Publisher();
$scholastic->setName("Scholastic");
// do not save, will do later to test cascade
print "Added publisher \"Scholastic\" [not saved yet].\n";
$morrow = new Publisher();
$morrow->setName("William Morrow");
$morrow->save();
$morrow_id = $morrow->getId();
print "Added publisher \"William Morrow\" [id = {$morrow_id}].\n";
$penguin = new Publisher();
$penguin->setName("Penguin");
$penguin->save();
$penguin_id = $penguin->getId();
print "Added publisher \"Penguin\" [id = {$penguin_id}].\n";
$vintage = new Publisher();
$vintage->setName("Vintage");
$vintage->save();
$vintage_id = $vintage->getId();
print "Added publisher \"Vintage\" [id = {$vintage_id}].\n";
} catch (Exception $e) {
die("Error adding publisher: " . $e->__toString());
}
// Add author records
// ------------------
try {
print "\nAdding some new authors to the list\n";
print "--------------------------------------\n\n";
$rowling = new Author();
$rowling->setFirstName("J.K.");
$rowling->setLastName("Rowling");
// no save()
示例7: testSaveReturnValues
/**
* Test saving an object and getting correct number of affected rows from save().
* This includes tests of cascading saves to fk-related objects.
*/
public function testSaveReturnValues()
{
$author = new Author();
$author->setFirstName("Mark");
$author->setLastName("Kurlansky");
// do not save
$pub = new Publisher();
$pub->setName("Penguin Books");
// do not save
$book = new Book();
$book->setTitle("Salt: A World History");
$book->setISBN("0142001619");
$book->setAuthor($author);
$book->setPublisher($pub);
$affected = $book->save();
$this->assertEquals(3, $affected, "Expected 3 affected rows when saving book + publisher + author.");
// change nothing ...
$affected = $book->save();
$this->assertEquals(0, $affected, "Expected 0 affected rows when saving already-saved book.");
// modify the book (UPDATE)
$book->setTitle("Salt A World History");
$affected = $book->save();
$this->assertEquals(1, $affected, "Expected 1 affected row when saving modified book.");
// modify the related author
$author->setLastName("Kurlanski");
$affected = $book->save();
$this->assertEquals(1, $affected, "Expected 1 affected row when saving book with updated author.");
// modify both the related author and the book
$author->setLastName("Kurlansky");
$book->setTitle("Salt: A World History");
$affected = $book->save();
$this->assertEquals(2, $affected, "Expected 2 affected rows when saving updated book with updated author.");
}
示例8: testDoInsert_Obj
/**
* Test the doInsert() method when passed a generated object.
*/
public function testDoInsert_Obj()
{
$name = "A Sample Publisher - " . time();
$values = new Publisher();
$values->setName($name);
PublisherPeer::doInsert($values);
$c = new Criteria();
$c->add(PublisherPeer::NAME, $name);
$matches = PublisherPeer::doSelect($c);
$this->assertEquals(1, count($matches), "Expect there to be exactly 1 publisher just-inserted.");
$this->assertTrue(1 != $matches[0]->getId(), "Expected to have different ID than one put in values Criteria.");
}
示例9: testNewObjectsGetLostOnJoin
public function testNewObjectsGetLostOnJoin()
{
/* While testNewObjectsAvailableWhenSaveNotCalled passed as of
revision 851, in this case we call getBooksJoinPublisher() instead
of just getBooks(). get...Join...() does not contain the check whether
the current object is new, it will always consult the DB and lose the
new objects entirely. Thus the test fails. (At least for Propel 1.2 ?!?) */
$this->markTestSkipped();
$a = new Author();
$a->setFirstName("Douglas");
$a->setLastName("Adams");
$p = new Publisher();
$p->setName('Pan Books Ltd.');
$b1 = new Book();
$b1->setTitle("The Hitchhikers Guide To The Galaxy");
$b1->setPublisher($p);
// uh... did not check that :^)
$a->addBook($b1);
$b2 = new Book();
$b2->setTitle("The Restaurant At The End Of The Universe");
$b2->setPublisher($p);
$a->addBook($b2);
$books = $a->getBooksJoinPublisher();
$this->assertEquals(2, count($books));
$this->assertContains($b1, $books);
$this->assertContains($b2, $books);
$a->save();
$this->assertFalse($b1->isNew());
$this->assertFalse($b2->isNew());
}
示例10: testSpeed
public function testSpeed()
{
// Add publisher records
// ---------------------
$scholastic = new Publisher();
$scholastic->setName("Scholastic");
// do not save, will do later to test cascade
$morrow = new Publisher();
$morrow->setName("William Morrow");
$morrow->save();
$morrow_id = $morrow->getId();
$penguin = new Publisher();
$penguin->setName("Penguin");
$penguin->save();
$penguin_id = $penguin->getId();
$vintage = new Publisher();
$vintage->setName("Vintage");
$vintage->save();
$vintage_id = $vintage->getId();
// Add author records
// ------------------
$rowling = new Author();
$rowling->setFirstName("J.K.");
$rowling->setLastName("Rowling");
// no save()
$stephenson = new Author();
$stephenson->setFirstName("Neal");
$stephenson->setLastName("Stephenson");
$stephenson->save();
$stephenson_id = $stephenson->getId();
$byron = new Author();
$byron->setFirstName("George");
$byron->setLastName("Byron");
$byron->save();
$byron_id = $byron->getId();
$grass = new Author();
$grass->setFirstName("Gunter");
$grass->setLastName("Grass");
$grass->save();
$grass_id = $grass->getId();
// Add book records
// ----------------
$phoenix = new Book();
$phoenix->setTitle("Harry Potter and the Order of the Phoenix");
$phoenix->setISBN("043935806X");
// cascading save (Harry Potter)
$phoenix->setAuthor($rowling);
$phoenix->setPublisher($scholastic);
$phoenix->save();
$phoenix_id = $phoenix->getId();
$qs = new Book();
$qs->setISBN("0380977427");
$qs->setTitle("Quicksilver");
$qs->setAuthor($stephenson);
$qs->setPublisher($morrow);
$qs->save();
$qs_id = $qs->getId();
$dj = new Book();
$dj->setISBN("0140422161");
$dj->setTitle("Don Juan");
$dj->setAuthor($byron);
$dj->setPublisher($penguin);
$dj->save();
$dj_id = $qs->getId();
$td = new Book();
$td->setISBN("067972575X");
$td->setTitle("The Tin Drum");
$td->setAuthor($grass);
$td->setPublisher($vintage);
$td->save();
$td_id = $td->getId();
// Add review records
// ------------------
$r1 = new Review();
$r1->setBook($phoenix);
$r1->setReviewedBy("Washington Post");
$r1->setRecommended(true);
$r1->setReviewDate(time());
$r1->save();
$r1_id = $r1->getId();
$r2 = new Review();
$r2->setBook($phoenix);
$r2->setReviewedBy("New York Times");
$r2->setRecommended(false);
$r2->setReviewDate(time());
$r2->save();
$r2_id = $r2->getId();
// Perform a "complex" search
// --------------------------
$crit = new Criteria();
$crit->add(BookPeer::TITLE, 'Harry%', Criteria::LIKE);
$results = BookPeer::doSelect($crit);
$crit2 = new Criteria();
$crit2->add(BookPeer::ISBN, array("0380977427", "0140422161"), Criteria::IN);
$results = BookPeer::doSelect($crit2);
// Perform a "limit" search
// ------------------------
$crit = new Criteria();
$crit->setLimit(2);
$crit->setOffset(1);
//.........这里部分代码省略.........
示例11: populate
public static function populate($con = null)
{
if ($con === null) {
$con = Propel::getConnection(BookPeer::DATABASE_NAME);
}
$con->beginTransaction();
// Add publisher records
// ---------------------
$scholastic = new Publisher();
$scholastic->setName("Scholastic");
// do not save, will do later to test cascade
$morrow = new Publisher();
$morrow->setName("William Morrow");
$morrow->save($con);
$morrow_id = $morrow->getId();
$penguin = new Publisher();
$penguin->setName("Penguin");
$penguin->save();
$penguin_id = $penguin->getId();
$vintage = new Publisher();
$vintage->setName("Vintage");
$vintage->save($con);
$vintage_id = $vintage->getId();
$rowling = new Author();
$rowling->setFirstName("J.K.");
$rowling->setLastName("Rowling");
// no save()
$stephenson = new Author();
$stephenson->setFirstName("Neal");
$stephenson->setLastName("Stephenson");
$stephenson->save($con);
$stephenson_id = $stephenson->getId();
$byron = new Author();
$byron->setFirstName("George");
$byron->setLastName("Byron");
$byron->save($con);
$byron_id = $byron->getId();
$grass = new Author();
$grass->setFirstName("Gunter");
$grass->setLastName("Grass");
$grass->save($con);
$grass_id = $grass->getId();
$phoenix = new Book();
$phoenix->setTitle("Harry Potter and the Order of the Phoenix");
$phoenix->setISBN("043935806X");
$phoenix->setAuthor($rowling);
$phoenix->setPublisher($scholastic);
$phoenix->setPrice(10.99);
$phoenix->save($con);
$phoenix_id = $phoenix->getId();
$qs = new Book();
$qs->setISBN("0380977427");
$qs->setTitle("Quicksilver");
$qs->setPrice(11.99);
$qs->setAuthor($stephenson);
$qs->setPublisher($morrow);
$qs->save($con);
$qs_id = $qs->getId();
$dj = new Book();
$dj->setISBN("0140422161");
$dj->setTitle("Don Juan");
$dj->setPrice(12.99);
$dj->setAuthor($byron);
$dj->setPublisher($penguin);
$dj->save($con);
$dj_id = $dj->getId();
$td = new Book();
$td->setISBN("067972575X");
$td->setTitle("The Tin Drum");
$td->setPrice(13.99);
$td->setAuthor($grass);
$td->setPublisher($vintage);
$td->save($con);
$td_id = $td->getId();
$r1 = new Review();
$r1->setBook($phoenix);
$r1->setReviewedBy("Washington Post");
$r1->setRecommended(true);
$r1->setReviewDate(time());
$r1->save($con);
$r1_id = $r1->getId();
$r2 = new Review();
$r2->setBook($phoenix);
$r2->setReviewedBy("New York Times");
$r2->setRecommended(false);
$r2->setReviewDate(time());
$r2->save($con);
$r2_id = $r2->getId();
$blob_path = _LOB_SAMPLE_FILE_PATH . '/tin_drum.gif';
$clob_path = _LOB_SAMPLE_FILE_PATH . '/tin_drum.txt';
$m1 = new Media();
$m1->setBook($td);
$m1->setCoverImage(file_get_contents($blob_path));
// CLOB is broken in PDO OCI, see http://pecl.php.net/bugs/bug.php?id=7943
if (get_class(Propel::getDB()) != "DBOracle") {
$m1->setExcerpt(file_get_contents($clob_path));
}
$m1->save($con);
// Add book list records
// ---------------------
//.........这里部分代码省略.........
示例12: testToStringUsesCustomStringFormat
public function testToStringUsesCustomStringFormat()
{
$coll = new PropelObjectCollection();
$coll->setModel('Publisher');
$publisher = new Publisher();
$publisher->setId(12345);
$publisher->setName('Penguinoo');
$coll[] = $publisher;
$expected = <<<EOF
<?xml version="1.0" encoding="UTF-8"?>
<data>
<Publisher>
<Id>12345</Id>
<Name><![CDATA[Penguinoo]]></Name>
</Publisher>
</data>
EOF;
$this->assertEquals($expected, (string) $coll);
}
示例13: testFindOneWithLeftJoinWithOneToManyAndNullObjectsAndWithAdditionalJoins
public function testFindOneWithLeftJoinWithOneToManyAndNullObjectsAndWithAdditionalJoins()
{
BookPeer::clearInstancePool();
AuthorPeer::clearInstancePool();
BookOpinionPeer::clearInstancePool();
BookReaderPeer::clearInstancePool();
$freud = new Author();
$freud->setFirstName("Sigmund");
$freud->setLastName("Freud");
$freud->save($this->con);
$publisher = new Publisher();
$publisher->setName('Psycho Books');
$publisher->save();
$book = new Book();
$book->setAuthor($freud);
$book->setTitle('Weirdness');
$book->setIsbn('abc123456');
$book->setPrice('14.99');
$book->setPublisher($publisher);
$book->save();
$query = BookQuery::create()->filterByTitle('Weirdness')->innerJoinAuthor()->useBookOpinionQuery(null, Criteria::LEFT_JOIN)->leftJoinBookReader()->endUse()->with('Author')->with('BookOpinion')->with('BookReader');
$books = $query->findOne($this->con);
$this->assertEquals(0, count($books->getBookOpinions()));
}
示例14: executeUpdate
public function executeUpdate()
{
$i18n = new sfI18N();
$i18n->initialize($this->getContext());
$i18n->setCulture($this->getUser()->getCulture());
$action_i18n = $i18n->globalMessageFormat->format('save as new');
$action_edit_i18n = $i18n->globalMessageFormat->format('edit');
$action_type = $this->getRequestParameter('action_type');
if ($action_type == $action_i18n || !$this->getRequestParameter('id', 0)) {
$catalog = new Catalog();
} else {
$catalog = CatalogPeer::retrieveByPk($this->getRequestParameter('id'));
$this->forward404Unless($catalog);
}
$catalog->setId($this->getRequestParameter('id'));
$catalog->setCatLanguageId($this->getRequestParameter('cat_language_id'));
$catalog->setCatCategoryId($this->getRequestParameter('cat_category_id'));
$catalog->setCatSubjectId($this->getRequestParameter('cat_subject_id'));
$catalog->setTitle($this->getRequestParameter('title'));
$catalog->setSubtitle($this->getRequestParameter('subtitle'));
$catalog->setPublishedYear($this->getRequestParameter('published_year'));
$catalog->setPublishedLocation($this->getRequestParameter('published_location'));
$catalog->setIsbn($this->getRequestParameter('isbn'));
$catalog->setStudentNo($this->getRequestParameter('student_no'));
$catalog->setStudentName($this->getRequestParameter('student_name'));
$catalog->setStudentMajor($this->getRequestParameter('student_major'));
$catalog->setStudentTutor($this->getRequestParameter('student_tutor'));
$catalog->setVersion($this->getRequestParameter('version'));
$catalog->setEdition($this->getRequestParameter('edition'));
$catalog->setPrintNo($this->getRequestParameter('print_no'));
$catalog->setPart($this->getRequestParameter('part'));
$catalog->setVolume($this->getRequestParameter('volume'));
$catalog->setMonth($this->getRequestParameter('month'));
$catalog->setYear($this->getRequestParameter('year'));
$catalog->setNo($this->getRequestParameter('no'));
$catalog->setBonus($this->getRequestParameter('bonus'));
$catalog->setPages($this->getRequestParameter('pages'));
$catalog->setHeight($this->getRequestParameter('height'));
$catalog->setSynopsis($this->getRequestParameter('synopsis'));
$catalog->setAbstracts($this->getRequestParameter('abstracts'));
$catalog->setSearchKeywords($this->getRequestParameter('search_keywords'));
//publisher
if ($action_type == $action_i18n || !$this->getRequestParameter('publisher_id')) {
$publisher = new Publisher();
$publisher->setId($this->getRequestParameter('publisher_id'));
$publisher->setName($this->getRequestParameter('publisher_name'));
$publisher->save();
$catalog->setPublisher($publisher);
$catalog->save();
} elseif ($action_type !== $action_i18n || !$this->getRequestParameter('publisher_id')) {
$publisher = new Publisher();
$publisher->setId($this->getRequestParameter('publisher_id'));
$publisher->setName($this->getRequestParameter('publisher_name'));
$publisher->save();
$catalog->setPublisher($publisher);
$catalog->save();
} elseif ($this->getRequestParameter('publisher_id')) {
$catalog->setPublisherId($this->getRequestParameter('publisher_id'));
$catalog->save();
}
//writer
#if ($this->getRequestParameter('cat_category_id') != 3 && $this->getRequestParameter('cat_category_id') != 2) {
if ($this->hasRequestParameter('writers_id') && $this->getRequestParameter('writers_id') != null && $this->getRequestParameter('writers_id') != '') {
$name = $this->getRequestParameter('writers_name');
$c = new Criteria();
$c->add(WriterPeer::NAME, "%{$name}%", Criteria::LIKE);
$rows = WriterPeer::doSelect($c);
if ($rows != null) {
$catalog->updateWriters($this->getRequestParameter('writers_name'));
$catalog->save();
} else {
$writer = new Writer();
$writer->setId($this->getRequestParameter('writers_id'));
$writer->setName($this->getRequestParameter('writers_name'));
$writer->save();
$cw = new CatalogWriter();
$cw->setCatalog($catalog);
$cw->setWriter($writer);
$cw->save();
}
} elseif ($action_type !== $action_i18n || !$this->getRequestParameter('writer_id')) {
$writer = new Writer();
$writer->setName($this->getRequestParameter('writers_name'));
$writer->save();
$cw = new CatalogWriter();
$cw->setCatalog($catalog);
$cw->setWriter($writer);
$cw->save();
} else {
$writer = new Writer();
$writer->setName($this->getRequestParameter('writers_name'));
$writer->save();
$cw = new CatalogWriter();
$cw->setCatalog($catalog);
$cw->setWriter($writer);
$cw->save();
}
#}
$writer_name = $catalog->getFirstWriterName();
$writer_name = preg_replace('/\\W+/', '', $writer_name);
//.........这里部分代码省略.........
示例15: getAllPublisher
function getAllPublisher()
{
$key = 'publisher';
$collection = CacheManager::get($key, TRUE);
if ($collection) {
return $collection;
}
$collection = new Collection();
$this->connect();
$result = $this->conn->query("CALL sp_get_all_publisher()");
if ($result) {
//$row = $result->fetch_assoc();
while ($obj = $result->fetch_object()) {
$publisher = new Publisher();
$publisher->setId($obj->Publisher_id);
$publisher->setName($obj->Name);
$publisher->setAddress($obj->Address);
$publisher->setPhone($obj->Phone);
$collection->addItem($publisher, $obj->Publisher_id);
}
$result->close();
// for fetch_object()
}
//$result->free_result(); // for fetch_assoc()
$this->close();
CacheManager::set($key, $collection, TRUE);
return $collection;
}