本文整理汇总了PHP中Author类的典型用法代码示例。如果您正苦于以下问题:PHP Author类的具体用法?PHP Author怎么用?PHP Author使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Author类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
示例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";
}
示例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;
}
示例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);
}
}
示例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()');
}
示例6: authorInsertion
function authorInsertion($firstName, $lastName)
{
$author = new \Author();
$author->setFirstName($firstName);
$author->setLastName($lastName);
$author->save();
return $author;
}
示例7: lol
public function lol()
{
$author = new Author();
$author->setFirstName('Jane' . rand(1, 100));
$author->setLastName('Austen' . rand(1, 100));
$author->save();
return $author;
}
示例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;
}
示例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;
}
示例10: runAuthorInsertion
function runAuthorInsertion($i)
{
$author = new Author();
$author->setFirstName('John' . $i);
$author->setLastName('Doe' . $i);
$author->save($this->con);
$this->authors[] = $author->getId();
}
示例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();
}
}
示例12: testUpdate
/** <tt>update test</tt> */
public function testUpdate()
{
$item = new Author();
$item->name = 'Andrei Cristescu';
$this->assertEqual($item->insert(), $item->id);
$item->email = 'cristescu@yahoo.com';
$this->assertEqual($item->update(), 1);
$this->assertEqual($item->delete(), 1);
}
示例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)");
}
}
示例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);
}
示例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;
}