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


PHP PMF_Utils::shuffleData方法代码示例

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


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

示例1: getAllTags

 /**
  * Returns all tags
  *
  * @param  string  $search Move the returned result set to be the result of a start-with search
  * @param  boolean $limit  Limit the returned result set
  * @return array
  */
 public function getAllTags($search = null, $limit = false)
 {
     global $DB;
     $tags = $allTags = array();
     // Hack: LIKE is case sensitive under PostgreSQL
     switch ($DB['type']) {
         case 'pgsql':
             $like = 'ILIKE';
             break;
         default:
             $like = 'LIKE';
             break;
     }
     $query = sprintf("\n            SELECT\n                tagging_id, tagging_name\n            FROM\n                %sfaqtags\n                %s\n            ORDER BY tagging_name", SQLPREFIX, isset($search) && $search != '' ? "WHERE tagging_name " . $like . " '" . $search . "%'" : '');
     $result = $this->db->query($query);
     if ($result) {
         while ($row = $this->db->fetchObject($result)) {
             $allTags[$row->tagging_id] = $row->tagging_name;
         }
     }
     $numberOfItems = $limit ? PMF_TAGS_CLOUD_RESULT_SET_SIZE : $this->db->numRows($result);
     if (isset($allTags) && $numberOfItems < count($allTags)) {
         $keys = array_keys($allTags);
         shuffle($keys);
         foreach ($keys as $current_key) {
             $tags[$current_key] = $allTags[$current_key];
         }
         $tags = array_slice($tags, 0, $numberOfItems);
     } else {
         $tags = PMF_Utils::shuffleData($allTags);
     }
     return $tags;
 }
开发者ID:nosch,项目名称:phpMyFAQ,代码行数:40,代码来源:Tags.php

示例2: getAllTags

 /**
  * Returns all tags
  *
  * @param  string  $search Move the returned result set to be the result of a start-with search
  * @param  boolean $limit  Limit the returned result set
  * @return array
  */
 public function getAllTags($search = null, $limit = false, $showInactive = false)
 {
     global $DB;
     $tags = $allTags = array();
     // Hack: LIKE is case sensitive under PostgreSQL
     switch ($DB['type']) {
         case 'pgsql':
             $like = 'ILIKE';
             break;
         default:
             $like = 'LIKE';
             break;
     }
     $query = sprintf("\n            SELECT\n                t.tagging_id AS tagging_id, t.tagging_name AS tagging_name\n            FROM\n                %sfaqtags t\n            LEFT JOIN\n                %sfaqdata_tags dt\n            ON\n                dt.tagging_id = t.tagging_id\n            LEFT JOIN\n                %sfaqdata d\n            ON\n                d.id = dt.record_id\n            WHERE\n                1=1\n                %s\n                %s\n            ORDER BY tagging_name", SQLPREFIX, SQLPREFIX, SQLPREFIX, $showInactive ? '' : "AND d.active = 'yes'", isset($search) && $search != '' ? "AND tagging_name " . $like . " '" . $search . "%'" : '');
     $result = $this->db->query($query);
     if ($result) {
         while ($row = $this->db->fetch_object($result)) {
             $allTags[$row->tagging_id] = $row->tagging_name;
         }
     }
     $numberOfItems = $limit ? PMF_TAGS_CLOUD_RESULT_SET_SIZE : $this->db->num_rows($result);
     if (isset($allTags) && $numberOfItems < count($allTags)) {
         $keys = array_keys($allTags);
         shuffle($keys);
         foreach ($keys as $current_key) {
             $tags[$current_key] = $allTags[$current_key];
         }
         $tags = array_slice($tags, 0, $numberOfItems, true);
     } else {
         $tags = PMF_Utils::shuffleData($allTags);
     }
     return $tags;
 }
开发者ID:atlcurling,项目名称:tkt,代码行数:40,代码来源:Tags.php


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