• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Author类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: testIssetWithOverloading

 public function testIssetWithOverloading()
 {
     include_once "php/mt.php";
     include_once "php/lib/MTUtil.php";
     $cfg_file = realpath("t/mysql-test.cfg");
     $mt = MT::get_instance(1, $cfg_file);
     $ctx =& $mt->context();
     // Test some objects inheriting ObjectBase class.
     require_once "php/lib/class.mt_config.php";
     $config = new Config();
     $config->Load();
     $this->assertTrue(isset($config->id));
     require_once "php/lib/class.mt_author.php";
     $author = new Author();
     $author->Load();
     $this->assertTrue(isset($author->id));
     // protected variable call (bugid:113105)
     require_once "php/lib/class.mt_entry.php";
     $entry = new Entry();
     $entry->id = 1;
     $this->assertTrue(isset($entry->id));
     $this->assertNull($entry->_prefix);
     $this->assertFalse(isset($entry->_prefix));
     // fixed Dynamic publishing error occurred with memcached environment. bugid: 113546
     $mt->config('MemcachedServers', '127.0.0.1:11211');
     $obj_names = array('asset' => 'Asset', 'author' => 'Author', 'blog' => 'Blog', 'category' => 'Category', 'comment' => 'Comment', 'entry' => 'Entry', 'folder' => 'Folder', 'page' => 'Page', 'tbping' => 'TBPing', 'template' => 'Template', 'website' => 'Website');
     foreach ($obj_names as $table => $name) {
         require_once "php/lib/class.mt_{$table}.php";
         $obj = new $name();
         $obj->Load();
         $this->cache("{$table}:" . $obj->id, $obj);
         $obj_cache = $this->load_cache("{$table}:" . $obj->id);
         $this->assertInstanceOf("{$name}", $obj_cache);
     }
 }
开发者ID:benvanstaveren,项目名称:movabletype,代码行数:35,代码来源:BaseObjectTest.php


示例2: generateRss

 private function generateRss()
 {
     $author = new Author();
     $author->clause('author_id', Application::param('author_id'));
     $posts = $author->also('Entry');
     $posts->order('entry_timestamp');
     $posts->descending();
     $posts->limit(10);
     $blog_entries = $posts->fetch();
     echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
     echo '<rss version="2.0">' . "\n";
     echo '    <channel>' . "\n";
     echo '        <title>' . $this->title() . '</title>' . "\n";
     echo '        <description>' . $this->description() . '</description>' . "\n";
     echo '        <link>' . $this->url() . '</link>' . "\n";
     foreach ($blog_entries as $entry) {
         echo '        <item>' . "\n";
         echo '            <title>' . $entry->get('entry_title') . '</title>' . "\n";
         echo '            <description>' . $entry->get('entry_body') . '</description>' . "\n";
         echo "            <link>'.{$this->url}().'/index.php?h=ViewBlogEntry</link>\n";
         echo '            <guid isPermalink="true">' . $this->url() . '/index.php?h=ViewBlogEntry&author_id=' . $entry->get('author_id') . '&entry_id=' . $entry->get('entry_id') . '</guid>' . "\n";
         echo '            <pubDate>' . $entry->entryDate() . '</pubDate>' . "\n";
         echo '        </item>' . "\n";
     }
     echo '    </channel>' . "\n";
     echo '</rss>' . "\n";
 }
开发者ID:k7n4n5t3w4rt,项目名称:SeeingSystem,代码行数:27,代码来源:blog_rss_feed.class.php


示例3: makeAuthor

 /**
  * Helper to create "Author" model for tests.
  *
  * @param $name
  * @return Author
  */
 protected function makeAuthor($name)
 {
     $author = new Author();
     $author->name = $name;
     $author->save();
     return $author;
 }
开发者ID:ChrisReid,项目名称:eloquent-sluggable,代码行数:13,代码来源:SluggableTest.php


示例4: insertBook

 public function insertBook($bookName, $bookAuthor)
 {
     $stmt = mysqli_prepare($this->connection, 'INSERT INTO books(book_title) VALUES (?)');
     mysqli_stmt_bind_param($stmt, 's', $bookName);
     mysqli_stmt_execute($stmt);
     $authorId = [];
     $author = new Author();
     $allAuthors = $author->selectAllAuthors();
     foreach ($bookAuthor as $au) {
         foreach ($allAuthors as $key => $value) {
             if ($au == $value) {
                 $authorId[] = $key;
             }
         }
     }
     $books = $this->getBook();
     $keyID = 0;
     foreach ($books as $key => $title) {
         if ($title == $bookName) {
             $keyID = $key;
         }
     }
     $stmt2 = mysqli_prepare($this->connection, 'INSERT INTO books_authors(book_id,author_id) VALUES (?,?)');
     for ($i = 0; $i < count($authorId); $i++) {
         mysqli_stmt_bind_param($stmt2, 'ii', $keyID, $authorId[$i]);
         mysqli_stmt_execute($stmt2);
     }
 }
开发者ID:Gecata-,项目名称:PHP,代码行数:28,代码来源:BookModel.php


示例5: 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()');
    }
开发者ID:ketheriel,项目名称:ETVA,代码行数:27,代码来源:OMBuilderTest.php


示例6: authorInsertion

 function authorInsertion($firstName, $lastName)
 {
     $author = new \Author();
     $author->setFirstName($firstName);
     $author->setLastName($lastName);
     $author->save();
     return $author;
 }
开发者ID:Big-Shark,项目名称:php-orm-benchmark,代码行数:8,代码来源:TestDefault.php


示例7: lol

 public function lol()
 {
     $author = new Author();
     $author->setFirstName('Jane' . rand(1, 100));
     $author->setLastName('Austen' . rand(1, 100));
     $author->save();
     return $author;
 }
开发者ID:xama5,项目名称:uver-erp,代码行数:8,代码来源:Test.php


示例8: runAuthorInsertion

 function runAuthorInsertion($i)
 {
     $author = new Author();
     $author->first_name = 'John' . $i;
     $author->last_name = 'Doe' . $i;
     $author->save($this->con);
     $this->authors[] = $author->id;
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:8,代码来源:Doctrine12TestSuite.php


示例9: post

 /**
  * Post name and email
  *
  * @param string $_name
  * @param string $_email
  *
  * return array {@type Author}
  *
  */
 public function post($_name, $_email)
 {
     $auth = new Author();
     $auth->name = $_name;
     $auth->email = $_email;
     $auth->save();
     return $auth;
 }
开发者ID:Alim-ifresco,项目名称:project1.dev4.why.sr,代码行数:17,代码来源:Authors.php


示例10: runAuthorInsertion

 function runAuthorInsertion($i)
 {
     $author = new Author();
     $author->setFirstName('John' . $i);
     $author->setLastName('Doe' . $i);
     $author->save($this->con);
     $this->authors[] = $author->getId();
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:8,代码来源:Propel17TestSuite.php


示例11: prepareData

 /**
  * prepareData
  */
 public function prepareData()
 {
     for ($i = 0; $i < 10; $i++) {
         $oAuthor = new Author();
         $oAuthor->book_id = $i;
         $oAuthor->name = "Author {$i}";
         $oAuthor->save();
     }
 }
开发者ID:swk,项目名称:bluebox,代码行数:12,代码来源:574TestCase.php


示例12: testUpdate

 /** <tt>update test</tt> */
 public function testUpdate()
 {
     $item = new Author();
     $item->name = 'Andrei Cristescu';
     $this->assertEqual($item->insert(), $item->id);
     $item->email = '[email protected]';
     $this->assertEqual($item->update(), 1);
     $this->assertEqual($item->delete(), 1);
 }
开发者ID:BackupTheBerlios,项目名称:medick-svn,代码行数:10,代码来源:DBOperationsTest.php


示例13: 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)");
     }
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:28,代码来源:CharacterEncodingTest.php


示例14: 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


示例15: checkAuthor

 function checkAuthor($author_name)
 {
     $new_author = null;
     if (Author::findByName($author_name)) {
         $new_author = Author::findByName($author_name);
     } else {
         $new_author = new Author($author_name);
         $new_author->save();
     }
     return $new_author;
 }
开发者ID:bdspen,项目名称:library_day1,代码行数:11,代码来源:Book.php


示例16: testResourcesFreeSimple

    public function testResourcesFreeSimple()
    {
        echo "Free Simple (BEFORE):" . (memory_get_usage() / 1024) . "<br/>";

        for ($i = 0; $i < 5000; $i++) {
            $author = new Author();
            $author->name = 'bar';
            $author->free(false);
        }

        echo "Free Simple (AFTER):" . (memory_get_usage() / 1024) . "<br/>";
    }
开发者ID:prismhdd,项目名称:victorioussecret,代码行数:12,代码来源:710TestCase.php


示例17: fetchByUsername

 public static function fetchByUsername($username)
 {
     $rec = Symphony::Database()->fetchRow(0, "SELECT * FROM `tbl_authors` WHERE `username` = '{$username}' LIMIT 1");
     if (!is_array($rec) || empty($rec)) {
         return NULL;
     }
     $author = new Author();
     foreach ($rec as $field => $val) {
         $author->set($field, $val);
     }
     return $author;
 }
开发者ID:bauhouse,项目名称:sym-calendar,代码行数:12,代码来源:class.authormanager.php


示例18: registerAction

 public function registerAction()
 {
     if ($this->request->isPost()) {
         $author = new Author();
         $data = $this->request->getPost('data');
         if (is_array($data) && count($data) > 0) {
             $data['password'] = password_hash($data['password'], PASSWORD_BCRYPT);
             $author->save($data);
             return $this->response->redirect('index/login');
         }
     }
 }
开发者ID:Akhundzade,项目名称:blog.today,代码行数:12,代码来源:IndexController.php


示例19: commenter

 public function commenter()
 {
     $commenter_id = $this->comment_commenter_id;
     if (empty($commenter_id) || !is_numeric($commenter_id)) {
         return;
     }
     require_once 'class.mt_author.php';
     $author = new Author();
     if ($author->Load("author_id = {$commenter_id}")) {
         return $author;
     }
     return null;
 }
开发者ID:OCMO,项目名称:movabletype,代码行数:13,代码来源:class.mt_comment.php


示例20: filterByAuthor

 /**
  * Filter the query by a related \Author object.
  * 
  * @param \Author|ObjectCollection $author The related object(s) to use as filter
  * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  * @return $this|BookQuery The current query, for fluid interface
  */
 public function filterByAuthor($author, $comparison = null)
 {
     if ($author instanceof \Author) {
         return $this->addUsingAlias(BookEntityMap::COL_AUTHORID, $author->getid(), $comparison);
     } elseif ($author instanceof ObjectCollection) {
         if (null === $comparison) {
             $comparison = Criteria::IN;
         }
         return $this->addUsingAlias(BookEntityMap::COL_AUTHORID, $author->toKeyValue('PrimaryKey', 'id'), $comparison);
     } else {
         throw new PropelException('filterByAuthor() only accepts arguments of type \\Author or Collection');
     }
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:20,代码来源:BaseBookQuery.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP AuthorPeer类代码示例发布时间:2022-05-23
下一篇:
PHP Authenticator类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap