本文整理汇总了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;
}
示例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;
}