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


PHP Tags::query方法代码示例

本文整理汇总了PHP中Tags::query方法的典型用法代码示例。如果您正苦于以下问题:PHP Tags::query方法的具体用法?PHP Tags::query怎么用?PHP Tags::query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tags的用法示例。


在下文中一共展示了Tags::query方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: tagsWithCounts

 public function tagsWithCounts()
 {
     if (null == $this->tagsWithCounts) {
         $this->tagsWithCounts = Tags::query()->rightJoin('Taggables', 'Tags.id = Taggables.tag_id')->leftJoin('Users', 'Taggables.user_id = Users.id')->where('Taggables.taggable_type = :type:', ['type' => get_class($this)])->andWhere('Taggables.taggable_id = :id:', ['id' => $this->id])->groupBy('Tags.id')->columns(['Tags.id', 'Tags.name AS name', 'COUNT(Users.name) AS counts'])->execute();
     }
     return $this->tagsWithCounts;
 }
开发者ID:huoybb,项目名称:movie,代码行数:7,代码来源:taggableTrait.php

示例2: getTags

 /**
  * Get tags associated with the current resource.
  *
  * @param int $limit Max. number of tags to return (0 = no limit)
  *
  * @return array
  * @access public
  */
 public function getTags($limit = 0)
 {
     $tagList = array();
     $query = 'SELECT MIN("tags"."id"), "tags"."tag", COUNT(*) as cnt ' . 'FROM "tags", "resource_tags"  ' . 'WHERE "tags"."id" = "resource_tags"."tag_id" ' . 'AND "tags"."id" IN (SELECT "resource_tags"."tag_id" ' . 'FROM "resource", "resource_tags" ' . 'WHERE "resource"."id" = "resource_tags"."resource_id" ' . 'AND "resource"."record_id" = ' . "'" . $this->escape($this->record_id) . "' " . 'AND "resource"."source" = ' . "'" . $this->escape($this->source) . "' " . ')' . 'GROUP BY "tags"."tag" ORDER BY cnt DESC, "tags"."tag"';
     $tag = new Tags();
     $tag->query($query);
     if ($tag->N) {
         while ($tag->fetch()) {
             $tagList[] = clone $tag;
             // Return prematurely if we hit the tag limit:
             if ($limit > 0 && count($tagList) >= $limit) {
                 return $tagList;
             }
         }
     }
     return $tagList;
 }
开发者ID:bharatm,项目名称:NDL-VuFind,代码行数:25,代码来源:Resource.php

示例3: getTagsRandom

 /**
  * Get random tags
  *
  * @return array
  */
 public static function getTagsRandom()
 {
     $tags = Tags::query()->orderBy('RAND()')->limit(10)->execute();
     if ($tags->valid()) {
         return $tags;
     }
     return false;
 }
开发者ID:gitter-badger,项目名称:phanbook,代码行数:13,代码来源:Tags.php

示例4: getAllTags

 public function getAllTags()
 {
     return $this->make('allTags', function () {
         $user = \Phalcon\Di::getDefault()->get('auth');
         return Tags::query()->leftJoin('Taggables', 'Taggables.tag_id = Tags.id')->where('Taggables.user_id = :user:', ['user' => $user->id])->groupBy('Tags.id')->orderBy('Tags.updated_at DESC')->execute();
     });
 }
开发者ID:huoybb,项目名称:standard,代码行数:7,代码来源:Tags.php

示例5: getTags

 /**
  * Get a list of all tags generated by the user in favorites lists.  Note that
  * the returned list WILL NOT include tags attached to records that are not
  * saved in favorites lists.
  *
  * @param int $resourceId Filter for tags tied to a specific resource (null
  * for no filter).
  * @param int $listId     Filter for tags tied to a specific list (null for no
  * filter).
  *
  * @return array
  * @access public
  */
 public function getTags($resourceId = null, $listId = null)
 {
     $tagList = array();
     $sql = 'SELECT MIN("tags"."id"), "tags"."tag", ' . 'COUNT("resource_tags"."id") AS cnt ' . 'FROM "tags", "resource_tags", "user_resource", "resource" ' . 'WHERE "tags"."id" = "resource_tags"."tag_id" ' . 'AND "user_resource"."user_id" = ' . "'" . $this->escape($this->id) . "' " . 'AND "user_resource"."resource_id" = "resource"."id" ' . 'AND "resource_tags"."user_id" = ' . "'" . $this->escape($this->id) . "' " . 'AND "resource"."id" = "resource_tags"."resource_id" ' . 'AND "user_resource"."list_id" = "resource_tags"."list_id" ';
     if (!is_null($resourceId)) {
         $sql .= 'AND "resource"."record_id" = ' . "'" . $this->escape($resourceId) . "' ";
     }
     if (!is_null($listId)) {
         $sql .= 'AND "resource_tags"."list_id" = ' . "'" . $this->escape($listId) . "' ";
     }
     $sql .= 'GROUP BY "tags"."tag" ORDER BY "tag"';
     $tag = new Tags();
     $tag->query($sql);
     if ($tag->N) {
         while ($tag->fetch()) {
             $tagList[] = clone $tag;
         }
     }
     return $tagList;
 }
开发者ID:bharatm,项目名称:NDL-VuFind,代码行数:33,代码来源:User.php

示例6: getTagsForList

 /**
  * Get tags associated with the current resource that the current user added.
  *
  * @access  public
  * @param   int     $limit          Max. number of tags to return (0 = no limit)
  * @return  array
  */
 function getTagsForList($listId, $limit = 10)
 {
     //Get a reference to the scope we are in.
     global $library;
     global $user;
     $tagList = array();
     $query = "SELECT tags.id as id, tags.tag " . "FROM tags inner join resource_tags on tags.id = resource_tags.tag_id " . "WHERE resource_id = '{$this->id}' and list_id = '{$listId}'" . "ORDER BY tags.tag LIMIT 0, {$limit}";
     $tag = new Tags();
     $tag->query($query);
     if ($tag->N) {
         //Load all bad words.
         require_once ROOT_DIR . '/Drivers/marmot_inc/BadWord.php';
         $badWords = new BadWord();
         $badWordsList = $badWords->getBadWordExpressions();
         while ($tag->fetch()) {
             //Determine if the current user added the tag
             $userAddedThis = false;
             if ($user) {
                 $rTag = new Resource_tags();
                 $rTag->tag_id = $tag->id;
                 $rTag->user_id = $user->id;
                 $rTag->find();
                 if ($rTag->N > 0) {
                     $userAddedThis = true;
                 }
             }
             $tag->userAddedThis = $userAddedThis;
             //Filter the tags prior to display to censor bad words
             $okToAdd = true;
             if (!$userAddedThis) {
                 //The user will always see their own tags no matter how filthy.
                 foreach ($badWordsList as $badWord) {
                     if (preg_match($badWord, trim($tag->tag))) {
                         $okToAdd = false;
                         break;
                     }
                 }
             }
             if ($okToAdd) {
                 $tagList[] = clone $tag;
                 // Return prematurely if we hit the tag limit:
                 if ($limit > 0 && count($tagList) >= $limit) {
                     return $tagList;
                 }
             }
         }
     }
     return $tagList;
 }
开发者ID:bryandease,项目名称:VuFind-Plus,代码行数:56,代码来源:Resource.php

示例7: _getTagCloud

 /**
  * Build an array of tag cloud information.
  *
  * @return array
  * @access private
  */
 private function _getTagCloud()
 {
     //global $interface;
     global $configArray;
     $tags = new Tags();
     // Specify different font sizes in descending order here
     $fontSizes = array(5, 4, 3, 2, 1);
     $nFonts = count($fontSizes);
     // no of different tags to display
     $RecLimit = 50;
     // Query to retrieve tags and their counts
     $query = 'SELECT "tags"."tag", COUNT("tag") as cnt ' . 'FROM "tags", "resource_tags" ' . 'WHERE "tags"."id" = "resource_tags"."tag_id" ' . 'GROUP BY "tags"."tag" ORDER BY cnt DESC, "tag" ' . "LIMIT {$RecLimit}";
     $tags->query($query);
     $actualRecs = $tags->N;
     // Create data array as
     // key = tag_name and value = tag_count
     //from the results returned by query
     $data = array();
     if ($actualRecs) {
         while ($tags->fetch()) {
             $data["{$tags->tag}"] = $tags->cnt;
         }
     } else {
         return;
     }
     $temp = $data;
     // sort array in alphabetical
     // order of its keys
     uksort($data, "strnatcasecmp");
     // Create arry which contains only
     // count of all tags
     $onlyCnt = array();
     foreach ($temp as $item) {
         $onlyCnt[] = $item;
     }
     // create array which will contain only
     // uniqe tag counts
     $DistinctValues = array($onlyCnt[0]);
     for ($i = 1; $i < count($onlyCnt); $i++) {
         if ($onlyCnt[$i] != $onlyCnt[$i - 1]) {
             $DistinctValues[] = $onlyCnt[$i];
         }
     }
     $cntDistinct = count($DistinctValues);
     // set step which will
     // decide when to change font size
     $step = 1;
     $mod = 0;
     if ($cntDistinct > $nFonts) {
         $step = (int) ($cntDistinct / $nFonts);
         $mod = $cntDistinct % $nFonts;
     }
     $distinctToFont = array();
     $fontIndex = 0;
     $stepCnt = 0;
     for ($i = 0; $i < $cntDistinct; $i++) {
         $distinctToFont["{$DistinctValues[$i]}"] = $fontSizes[$fontIndex];
         $stepCnt++;
         if ($mod && $nFonts - ($fontIndex + 1) == $mod) {
             $step++;
             $fontIndex++;
             $stepCnt = 0;
         }
         if ($stepCnt == $step) {
             $fontIndex++;
             $stepCnt = 0;
         }
     }
     foreach ($data as $key => $value) {
         $data[$key] = array("font" => $distinctToFont["{$value}"], "count" => $value);
     }
     return $data;
 }
开发者ID:bharatm,项目名称:NDL-VuFind,代码行数:79,代码来源:TagCloud.php

示例8: getTagList

 /**
  * Get a list of tags based on current GET parameters.
  *
  * @access  private
  * @param   string      $extra_where        Where clause to add to lookup query;
  *                                          it is caller's responsibility to
  *                                          make sure this is safe!!
  * @return  array                           Tag details.
  */
 private function getTagList($extra_where = '')
 {
     $tagList = array();
     $tag = new Tags();
     $sql = "SELECT tags.tag, COUNT(resource_tags.id) as cnt " . "FROM tags, resource_tags " . "WHERE tags.id = resource_tags.tag_id{$extra_where} GROUP BY tags.tag";
     switch ($_GET['findby']) {
         case 'alphabetical':
             $sql .= " ORDER BY tags.tag, cnt DESC";
             break;
         case 'popularity':
             $sql .= " ORDER BY cnt DESC, tags.tag";
             break;
         case 'recent':
             $sql .= " ORDER BY resource_tags.posted DESC, cnt DESC, tags.tag";
             break;
     }
     // Limit the size of our results based on the ini browse limit setting
     $browseLimit = isset($configArray['Browse']['result_limit']) ? $configArray['Browse']['result_limit'] : 100;
     $sql .= " LIMIT " . $browseLimit;
     $tag->query($sql);
     if ($tag->N) {
         while ($tag->fetch()) {
             $tagList[] = clone $tag;
         }
     }
     return $tagList;
 }
开发者ID:bryandease,项目名称:VuFind-Plus,代码行数:36,代码来源:Tag.php

示例9: indexAction

 public function indexAction($page = 1)
 {
     $tags = Tags::query()->orderBy('updated_at DESC')->execute();
     $this->view->page = $this->getPaginator($tags, 25, $page);
 }
开发者ID:huoybb,项目名称:standard,代码行数:5,代码来源:TagsController.php

示例10: _getTagList

 /**
  * Get a list of tags based on current GET parameters.
  *
  * @param string $extra_where Where clause to add to lookup query; it is the
  * caller's responsibility to make sure this is safe!!
  *
  * @return array              Tag details.
  * @access private
  */
 private function _getTagList($extra_where = '')
 {
     $tagList = array();
     $tag = new Tags();
     $sql = 'SELECT "tags"."tag", COUNT("resource_tags"."id") AS cnt ' . 'FROM "tags", "resource_tags" ' . 'WHERE "tags"."id" = "resource_tags"."tag_id"' . $extra_where . ' GROUP BY "tags"."tag"';
     switch ($_GET['findby']) {
         case 'alphabetical':
             $sql .= ' ORDER BY "tags"."tag", cnt DESC';
             break;
         case 'popularity':
             $sql .= ' ORDER BY cnt DESC, "tags"."tag"';
             break;
         case 'recent':
             $sql .= ' ORDER BY max("resource_tags"."posted") DESC, cnt DESC, ' . '"tags"."tag"';
             break;
     }
     // Limit the size of our results based on the ini browse limit setting
     $browseLimit = isset($configArray['Browse']['result_limit']) ? $configArray['Browse']['result_limit'] : 100;
     $sql .= " LIMIT " . $browseLimit;
     $tag->query($sql);
     if ($tag->N) {
         while ($tag->fetch()) {
             $tagList[] = clone $tag;
         }
     }
     return $tagList;
 }
开发者ID:bharatm,项目名称:NDL-VuFind,代码行数:36,代码来源:Tag.php

示例11: getTags

 function getTags($resourceId = null, $listId = null)
 {
     require_once 'Resource_tags.php';
     require_once 'Tags.php';
     $tagList = array();
     $sql = "SELECT tags.id, tags.tag, COUNT(resource_tags.id) AS cnt " . "FROM tags INNER JOIN resource_tags on tags.id = resource_tags.tag_id " . "INNER JOIN resource on resource_tags.resource_id = resource.id WHERE " . "resource_tags.user_id = '{$this->id}' ";
     if (!is_null($resourceId)) {
         $sql .= "AND resource.record_id = '{$resourceId}' ";
     }
     if (!is_null($listId)) {
         $sql .= "AND resource_tags.list_id = '{$listId}' ";
     }
     $sql .= "GROUP BY tags.tag ORDER BY cnt DESC, tags.tag ASC";
     $tag = new Tags();
     $tag->query($sql);
     if ($tag->N) {
         while ($tag->fetch()) {
             $tagList[] = clone $tag;
         }
     }
     return $tagList;
 }
开发者ID:bryandease,项目名称:VuFind-Plus,代码行数:22,代码来源:User.php

示例12: tags

 public function tags()
 {
     if (null == $this->tags) {
         $this->tags = Tags::query()->join('Taggables', 'Taggables.tag_id = Tags.id')->where('Taggables.user_id = :user:', ['user' => $this->id])->groupBy('Tags.id')->execute();
     }
     return $this->tags;
 }
开发者ID:huoybb,项目名称:movie,代码行数:7,代码来源:Users.php


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