本文整理汇总了PHP中Tag::fetch方法的典型用法代码示例。如果您正苦于以下问题:PHP Tag::fetch方法的具体用法?PHP Tag::fetch怎么用?PHP Tag::fetch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tag
的用法示例。
在下文中一共展示了Tag::fetch方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testIncrement
public function testIncrement()
{
$name = 'iphone';
$tag = Tag::fetch($name);
$count = $tag->frequency;
$tag->increment();
$tag2 = Tag::fetch($name);
$this->assertEquals($count + 1, $tag2->frequency);
}
示例2: testUpdate
public function testUpdate()
{
$tag = 'iphone';
$pk = array('site_id' => TagSite::getSiteId('ent'), 'news_id' => util_genId(21));
$tag_id = Tag::fetch($tag)->id;
$data = $pk + array('time' => util_time(10), 'type' => 0);
$result = TagArticles::model()->index($tag_id, $data);
//$this->assertTrue($result);
$articles = TagArticles::model()->search($tag_id);
$article = $articles[0];
$this->assertEquals($pk['news_id'], $article['news_id']);
$this->assertEquals($pk['site_id'], $article['site_id']);
$result = TagArticles::model()->removeIndex($tag_id, $data);
//$this->assertTrue($result);
}
示例3: testTagsIndexMobile
public function testTagsIndexMobile()
{
$tags = array('iphone', 'ipad');
$site_id = TagSite::getSiteId('news');
//'news';
$news_id = util_genId(51);
$indexer = new TagArticles();
$tag_id = Tag::fetch('iphone')->id;
$rows = $indexer->search($tag_id, 0, 0, 'mobile', 1);
$this->assertEquals(1, count($rows));
$this->assertEquals($news_id, $rows[0]['news_id']);
$article = new ArticleTags();
$article->setAttributes(array('site_id' => $site_id, 'news_id' => $news_id, 'time' => util_time(23), 'type' => 0, 'source' => 'mobile'));
$result = $article->saveTags($tags);
$this->assertTrue($result);
$rows = $indexer->search($tag_id, 0, 0, 'web', 1);
$this->assertEquals(1, count($rows));
$this->assertEquals($news_id, $rows[0]['news_id']);
$rows = $indexer->search($tag_id, 0, 0, 'mobile', 1);
$this->assertEquals(1, count($rows));
$this->assertEquals($news_id, $rows[0]['news_id']);
}
示例4: onArticleRemoveTag
protected function onArticleRemoveTag($data)
{
$tag = Tag::fetch($data['tag']);
if ($tag) {
$tag->increment(-1);
} else {
return false;
}
unset($data['tag']);
$item = new TagArticles();
$item->removeIndex($tag->id, $data);
return true;
}
示例5: _listByTag
public function _listByTag($tag, $site_id = 'all', $page = 1, $len = 20)
{
$news_list = array();
do {
$record = Tag::fetch($tag);
if (!$record) {
break;
}
$len = intval($len);
$page = intval($page) > 0 ? intval($page) : 1;
$offset = ($page - 1) * $len;
$rows = TagArticles::model()->search($record->id, $site_id, $len, $offset);
if (empty($rows)) {
break;
}
$pks = array();
foreach ($rows as $row) {
$site = TagsSite::getSite($row['site_id']);
$pks[] = array($site, $row['news_id']);
}
$news_list = ArticleMini::model()->findArticles($pks);
} while (0);
return $news_list;
}