当前位置: 首页>>代码示例>>PHP>>正文


PHP Author::setName方法代码示例

本文整理汇总了PHP中Author::setName方法的典型用法代码示例。如果您正苦于以下问题:PHP Author::setName方法的具体用法?PHP Author::setName怎么用?PHP Author::setName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Author的用法示例。


在下文中一共展示了Author::setName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testSetname

 function testSetname()
 {
     //Arrange
     $name = "Mary Shelly";
     $test_author = new Author($name);
     //Act
     $test_author->setName("Dean Koontz");
     $result = $test_author->getName();
     //Assert
     $this->assertEquals("Dean Koontz", $result);
 }
开发者ID:Camolot,项目名称:library,代码行数:11,代码来源:AuthorTest.php

示例2: Author

 function test_setName()
 {
     //Arrange
     $name = "Kevin";
     $test_author = new Author($name);
     //Act
     $name2 = "Ian";
     $test_author->setName($name2);
     $result = $test_author->getName();
     //Assert
     $this->assertEquals($name2, $result);
 }
开发者ID:kevintokheim,项目名称:Liberry,代码行数:12,代码来源:AuthorTest.php

示例3: testSetName

 function testSetName()
 {
     //Arrange
     $name = "Paul Jones";
     $id = 1;
     $test_author = new Author($name, $id);
     //Act
     $test_author->setName("Steve Smith");
     $result = $test_author->getName();
     //Assert
     $this->assertEquals("Steve Smith", $result);
 }
开发者ID:bborealis,项目名称:library-1,代码行数:12,代码来源:AuthorTest.php

示例4: Author

 function test_setName()
 {
     //Arrange
     $name = "Stephen King";
     $id = null;
     $test_author = new Author($name, $id);
     //Act
     $test_author->setName("James Patterson");
     $result = $test_author->getName();
     //Assert
     $this->assertEquals("James Patterson", $result);
 }
开发者ID:jlbethel,项目名称:library-1,代码行数:12,代码来源:AuthorTest.php

示例5: save

 public function save($data)
 {
     $ret = parent::save($data);
     if (isset($data['author'])) {
         $id = $this->getId();
         $authors = explode(";", $data['author']);
         foreach ($authors as $author) {
             $a = new Author();
             $a->setName($author);
             $a->commit();
             $bookAuthor = new BookAuthor();
             $bookAuthor->setBookId($id);
             $bookAuthor->setAuthorId($a->getId());
             $bookAuthor->commit();
         }
     }
     return $ret;
 }
开发者ID:manishkhanchandani,项目名称:mkgxy,代码行数:18,代码来源:Book.php

示例6: function

    }
    $title = $request->request->get('title');
    $message = $request->request->get('message');
    $postModel->set($title, $message, $authorId);
    return $app->redirect($app["url_generator"]->generate("post_index"));
})->bind('post_add');
$app->get('/authors', function () use($app) {
    $authorModel = new Author($app['db']);
    $authorsToDisplay = $authorModel->getAll();
    return $app['twig']->render('author_index.html.twig', array('authors' => $authorsToDisplay));
})->bind('author_index');
$app->get('/author/{author_id}', function ($author_id) use($app) {
    $authorModel = new Author($app['db']);
    $authorToDisplay = $authorModel->get($author_id);
    if (!$authorToDisplay) {
        $app->abort(404, 'The article could not be found');
    }
    return $app['twig']->render('author_single.html.twig', array('author' => $authorToDisplay));
})->assert('author_id', '\\d+')->bind('author_single');
$app->get('/author/new', function () use($app) {
    return $app['twig']->render('author_new.html.twig');
})->bind('author_new');
$app->post('/author/add', function (Request $request) use($app) {
    $authorModel = new Author($app['db']);
    $name = $request->request->get('name');
    $authorModel->setName($name);
    return $app->redirect($app["url_generator"]->generate("author_index"));
})->bind('author_add');
// This should be the last line
$app->run();
// Start the application, i.e. handle the request
开发者ID:marchage,项目名称:phpsilexblog,代码行数:31,代码来源:index.php

示例7: dirname

<?php

/*
 * This file is part of the symfony package.
 * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
$app = 'frontend';
include dirname(__FILE__) . '/../../bootstrap/functional.php';
include $configuration->getSymfonyLibDir() . '/vendor/lime/lime.php';
$t = new lime_test(2);
// ->__construct()
$t->diag('->__construct()');
class DefaultValuesForm extends AuthorForm
{
    public function configure()
    {
        $this->setDefault('name', 'John Doe');
    }
}
$author = new Author();
$form = new DefaultValuesForm($author);
$t->is($form->getDefault('name'), 'John Doe', '->__construct() uses form defaults for new objects');
$author = new Author();
$author->setName('Jacques Doe');
$author->save();
$form = new DefaultValuesForm($author);
$t->is($form->getDefault('name'), 'Jacques Doe', '->__construct() uses object value as a default for existing objects');
$author->delete();
开发者ID:sensorsix,项目名称:app,代码行数:31,代码来源:sfFormPropelTest.php

示例8: dirname

/*
 * This file is part of the symfony package.
 * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
 * 
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
$app = 'frontend';
$fixtures = 'fixtures/fixtures.yml';
require_once dirname(__FILE__) . '/../bootstrap/functional.php';
$t = new lime_test(22);
$authors = Doctrine_Core::getTable('Author')->findAll();
$t->is(count($authors), 2);
$author = new Author();
// Accessor overriding
$author->setName('Jonathan H. Wage');
$author->save();
// Propel style accessors with column name
$t->is($author->getName(), $author->name);
// Propel style accessors for id
// Also check new author was not created since Jonathan H. Wage exists in fixtures/fixtures.yml
$t->is($author->getId(), 1);
// Make sure we still have only 2 authors
$authors = Doctrine_Core::getTable('Author')->findAll();
$t->is(count($authors), 2);
$article = new Article();
$article->title = 'test';
// __toString() automatic column finder
$t->is((string) $article, 'test');
// Different style accessors
$t->is($article->getAuthor_id(), $article->author_id);
开发者ID:Phennim,项目名称:symfony1,代码行数:31,代码来源:sfDoctrineRecordTest.php

示例9: testTransactions

 public function testTransactions()
 {
     $author = new Author();
     $author->setName('Haruki Murakami');
     $this->assertTrue($author->save());
     $db = Author::getDb();
     $db->startTransaction();
     $db->delete('author', array(1 => 1));
     $db->rollback();
     $authors = new Author_Collection();
     $authors->load();
     $this->assertEqual(count($authors), 1);
 }
开发者ID:jmhobbs,项目名称:MkLst,代码行数:13,代码来源:TestCoughObject.class.php

示例10: table

$t->is($nbArticles, 1, 'join() allows to join to another table (one-to-many)');
$nbArticles = sfPropelFinder::from('Article')->where('Comment.Content', 'foo')->count();
$t->is($nbArticles, 1, 'join() can be omitted if column names are explicit (one-to-many)');
$article = sfPropelFinder::from('Article')->join('Comment')->where('Comment.Content', 'foo')->findOne();
$t->is($article->getTitle(), 'bbbbb', 'join() allows to join to another table (one-to-many)');

CommentPeer::doDeleteAll();
ArticlePeer::doDeleteAll();
AuthorPeer::doDeleteAll();

$article1 = new Article();
$article1->setTitle('aaaaa');
$article1->setCategory($category1);
$article1->save();
$author1 = new Author();
$author1->setName('John');
$author1->save();
$comment = new Comment();
$comment->setContent('foo');
$comment->setArticleId($article1->getId());
$comment->setAuthor($author1);
$comment->save();
$article = sfPropelFinder::from('Article')->join('Comment')->join('Author')->where('Author.Name', 'John')->findOne();
$t->is($article->getTitle(), 'aaaaa', 'you can chain several join() statements');
$article = sfPropelFinder::from('Article')->join('Comment')->where('Author.Name', 'John')->findOne();
$t->is($article->getTitle(), 'aaaaa', 'join() can be omitted if column names are explicit');
$article = sfPropelFinder::from('Article')->joinComment()->joinAuthor()->where('Author.Name', 'John')->findOne();
$t->is($article->getTitle(), 'aaaaa', 'joinXXX() does a join according to the XXX column name');

$comment = sfPropelFinder::from('Comment')->join('Article')->join('Author')->where('Author.Name', 'John')->findOne();
$t->is($comment->getContent(), 'foo', 'you can add several join() statements');
开发者ID:jonphipps,项目名称:Metadata-Registry,代码行数:31,代码来源:sfPropelFinderJoinTest.php

示例11: getAllAuthor

 function getAllAuthor()
 {
     $key = 'author';
     $collection = CacheManager::get($key, TRUE);
     if ($collection) {
         return $collection;
     }
     $collection = new Collection();
     $this->connect();
     $result = $this->conn->query("CALL sp_get_all_author()");
     if ($result) {
         //$row = $result->fetch_assoc();
         while ($obj = $result->fetch_object()) {
             $author = new Author();
             $author->setId($obj->Author_id);
             $author->setName($obj->Author_name);
             $collection->addItem($author, $obj->Author_id);
         }
         $result->close();
         // for fetch_object()
     }
     //$result->free_result(); // for fetch_assoc()
     $this->close();
     CacheManager::set($key, $collection, TRUE);
     return $collection;
 }
开发者ID:VuECASydney,项目名称:LibraryManagement,代码行数:26,代码来源:DBConnection.php

示例12: Article

$t->diag('sfPropelFinder::with() does not fail with two left joins and missing related objects');

CommentPeer::doDeleteAll();
ArticlePeer::doDeleteAll();
Articlei18nPeer::doDeleteAll();
AuthorPeer::doDeleteAll();

$article1 = new Article();
$article1->setTitle('aaa');
$article1->save();
$comment1 = new Comment();
$comment1->setArticleId($article1->getId());
$comment1->save();
$author1 = new Author();
$author1->setName('auth1');
$author1->save();
$comment2 = new Comment();
$comment2->setArticleId($article1->getId());
$comment2->setAuthor($author1);
$comment2->save();

$finder = sfPropelFinder::from('Comment')->
  leftJoin('Author')->with('Author')->
  leftJoin('Article')->with('Article');
$comments = $finder->find();
$latestQuery = $finder->getLatestQuery();
$t->is($comments[0]->getAuthor(), null, 'First object has no author');
$t->is(Propel::getConnection()->getLastExecutedQuery(), $latestQuery, 'Related hydration occurred correctly');
$t->isnt($comments[0]->getArticle(), null, 'First object has an article');
$t->is(Propel::getConnection()->getLastExecutedQuery(), $latestQuery, 'Related hydration occurred correctly');
开发者ID:jonphipps,项目名称:Metadata-Registry,代码行数:30,代码来源:sfPropelFinderWithTest.php

示例13: getAuthors

    }
    public function getAuthors()
    {
        return $this->related(new Author());
    }
}
class Author extends RedBean_DomainObject
{
    public function setName($name)
    {
        $this->bean->name = $name;
    }
    public function getName()
    {
        return $this->bean->name;
    }
}
$book = new Book();
$author = new Author();
$book->setTitle("A can of beans");
$author->setName("Mr. Bean");
$book->addAuthor($author);
$id = $book->getID();
$book2 = new Book();
$book2->find($id);
asrt($book2->getTitle(), "A can of beans");
$authors = $book2->getAuthors();
asrt(count($authors), 1);
$he = array_pop($authors);
asrt($he->getName(), "Mr. Bean");
printtext("\nALL TESTS PASSED. REDBEAN SHOULD WORK FINE.\n");
开发者ID:surfnjunkie,项目名称:redbean,代码行数:31,代码来源:test.php

示例14: dirname

/*
 * This file is part of the symfony package.
 * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
$app = 'frontend';
include dirname(__FILE__) . '/../../bootstrap/functional.php';
include $configuration->getSymfonyLibDir() . '/vendor/lime/lime.php';
$t = new lime_test(2);
// ->clean()
$t->diag('->clean()');
$validator = new sfValidatorPropelUnique(array('model' => 'Author', 'column' => 'name'));
$author = new Author();
$author->setName('==NAME==');
$author->save();
try {
    $validator->clean(array('name' => '==NAME=='));
    $t->fail('->clean() throws an error on the column');
} catch (sfValidatorErrorSchema $errors) {
    $t->is(isset($errors['name']), true, '->clean() throws an error on the column');
} catch (Exception $e) {
    $t->fail('->clean() throws an error on the column');
    $t->diag('    ' . $e->getMessage());
}
$validator->setOption('field', 'author_name');
try {
    $validator->clean(array('author_name' => '==NAME=='));
    $t->fail('->clean() throws an error on the field');
} catch (sfValidatorErrorSchema $errors) {
开发者ID:sensorsix,项目名称:app,代码行数:31,代码来源:sfValidatorPropelUniqueTest.php

示例15: JsonResolver

<?php

use Gries\JsonObjectResolver\JsonResolver;
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/Author.php';
require_once __DIR__ . '/Book.php';
$book = new \Book();
$book->setTitle('test-title-1');
$book2 = new \Book();
$book2->setTitle('test-title-2');
$author = new \Author();
$author->setName('test-author');
$author->setBooks([$book, $book2]);
$resolver = new JsonResolver();
$json = $resolver->encode($author);
$decodedAuthor = $resolver->decode($json);
var_dump($author);
var_dump($decodedAuthor);
//class Author#4 (2) {
//  protected $name =>
//  string(11) "test-author"
//  protected $books =>
//  array(2) {
//    [0] =>
//    class Book#2 (1) {
//      protected $title =>
//      string(12) "test-title-1"
//    }
//    [1] =>
//    class Book#3 (1) {
//      protected $title =>
开发者ID:gries,项目名称:json-resolver,代码行数:31,代码来源:complex.php


注:本文中的Author::setName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。