当前位置: 首页>>代码示例>>PHP>>正文


PHP Tag::fetch方法代码示例

本文整理汇总了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);
 }
开发者ID:reedboat,项目名称:TagProject,代码行数:9,代码来源:TagTest.php

示例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);
 }
开发者ID:reedboat,项目名称:TagProject,代码行数:15,代码来源:TagArticleTest.php

示例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']);
 }
开发者ID:reedboat,项目名称:TagProject,代码行数:22,代码来源:ArticleTagsTest.php

示例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;
 }
开发者ID:reedboat,项目名称:TagProject,代码行数:13,代码来源:ArticleTags.inc.php

示例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;
 }
开发者ID:reedboat,项目名称:TagProject,代码行数:24,代码来源:Tags.inc.php


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