本文整理匯總了PHP中TagPeer::retriveByName方法的典型用法代碼示例。如果您正苦於以下問題:PHP TagPeer::retriveByName方法的具體用法?PHP TagPeer::retriveByName怎麽用?PHP TagPeer::retriveByName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類TagPeer
的用法示例。
在下文中一共展示了TagPeer::retriveByName方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: parseItem
function parseItem($blog, $item, $ts)
{
if ($ts != 0 && $item->pubdate <= $ts) {
logmsg('Zatrzymanie na wpisie: %s', StringUtils::removeAccents($item->title));
return false;
}
logmsg(' - Parsowanie wpisu: %s', StringUtils::removeAccents($item->title));
$post = new Post();
$post->setBlog($blog);
foreach ($item->tags as $name) {
$tag = TagPeer::retriveByName($name, true);
if ($post->addTag($tag)) {
logmsg(' - Znaleziono tag: %s', $name);
}
}
if ($post->hasTags()) {
$shortened = $post->setFullContent($item->content);
$post->setLink(htmlspecialchars($item->link));
$post->setTitle($item->title);
$post->setCreatedAt($item->pubdate);
$post->setShortened($shortened);
$post->save();
} else {
logmsg(' - Nie znaleziono tagow');
}
return true;
}
示例2: executeRefresh
public function executeRefresh()
{
$post = PostPeer::retrieveByPK($this->getRequestParameter('id'));
$blog = $post->getBlog();
$this->forward404Unless($blog->getId() == $this->getUser()->getId());
if ($post) {
try {
$items = FeedParser::parse($blog->getFeed());
foreach ($items as $item) {
if ($item->link == $post->getLink()) {
$post->removeTags();
foreach ($item->tags as $name) {
$tag = TagPeer::retriveByName($name, true);
$post->addTag($tag);
}
if ($post->hasTags()) {
$shortened = $post->setFullContent($item->content);
$post->setLink($item->link);
$post->setTitle($item->title);
$post->setCreatedAt($item->pubdate);
$post->setShortened($shortened);
$post->save();
}
break;
}
}
$this->setFlash('updated', 'Wpis został odświeżony.');
} catch (Exception $e) {
$this->setFlash('updated', 'Odswieżanie wpisu nie powiodło się.');
}
}
$this->redirect('ucp/index');
}