本文整理汇总了PHP中Feed::setId方法的典型用法代码示例。如果您正苦于以下问题:PHP Feed::setId方法的具体用法?PHP Feed::setId怎么用?PHP Feed::setId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Feed
的用法示例。
在下文中一共展示了Feed::setId方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testToAPI
public function testToAPI()
{
$feed = new Feed();
$feed->setId(3);
$feed->setUrl('http://google');
$feed->setTitle('title');
$feed->setFaviconLink('favicon');
$feed->setAdded(123);
$feed->setFolderId(1);
$feed->setUnreadCount(321);
$feed->setLink('https://google');
$this->assertEquals(array('id' => 3, 'url' => 'http://google', 'title' => 'title', 'faviconLink' => 'favicon', 'added' => 123, 'folderId' => 1, 'unreadCount' => 321, 'link' => 'https://google'), $feed->toAPI());
}
示例2: createFeed
private function createFeed()
{
$feed = new Feed();
$feed->setId(3);
$feed->setLastModified(44);
$feed->setEtag(45);
$feed->setUrl('http://google.com/some/weird/path');
$feed->setTitle('title');
$feed->setFaviconLink('favicon');
$feed->setAdded(123);
$feed->setFolderId(1);
$feed->setUnreadCount(321);
$feed->setLink('https://www.google.com/some/weird/path');
$feed->setLocation('http://google.at');
$feed->setOrdering(2);
return $feed;
}
示例3: testDelete
public function testDelete()
{
$feed = new Feed();
$feed->setId(3);
$sql = 'DELETE FROM `*PREFIX*news_feeds` WHERE `id` = ?';
$arguments = [$feed->getId()];
$sql2 = 'DELETE FROM `*PREFIX*news_items` WHERE `feed_id` = ?';
$arguments2 = [$feed->getId()];
$pdoResult = $this->getMock('Result', ['fetch']);
$pdoResult->expects($this->any())->method('fetch');
$this->setMapperResult($sql, $arguments);
$this->setMapperResult($sql2, $arguments2);
$this->mapper->delete($feed);
}
示例4: save
public function save(Feed $feed, $folderid)
{
$title = $feed->getTitle();
$url = $feed->getUrl();
$url_hash = md5($url);
if (empty($title)) {
$l = \OC_L10N::get('news');
$title = $l->t('no title');
}
$favicon = $feed->getFavicon();
//FIXME: Detect when feed contains already a database id
$feedid = $this->findIdFromUrl($url);
if ($feedid === null) {
$query = \OCP\DB::prepare("\n\t\t\t\tINSERT INTO " . self::tableName . "(url, url_hash, title, favicon_link, folder_id, user_id, added, lastmodified)\n\t\t\t\tVALUES (?, ?, ?, ?, ?, ?, UNIX_TIMESTAMP(), UNIX_TIMESTAMP())\n\t\t\t\t");
$params = array($url, $url_hash, $title, $favicon, $folderid, $this->userid);
$query->execute($params);
$feedid = \OCP\DB::insertid(self::tableName);
} else {
//update the db. it needs to be done, since it might be the first save after a full fetch
$stmt = \OCP\DB::prepare('
UPDATE ' . self::tableName . ' SET favicon_link = ? , lastmodified = UNIX_TIMESTAMP() , folder_id = ?
WHERE id = ?
');
$params = array($favicon, $folderid, $feedid);
$stmt->execute($params);
}
$feed->setId($feedid);
$itemMapper = new ItemMapper();
$items = $feed->getItems();
if ($items !== null) {
foreach ($items as $item) {
$itemMapper->save($item, $feedid);
}
}
return $feedid;
}