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


PHP CriteriaCompo::getOrder方法代码示例

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


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

示例1: getActiveModules

 function getActiveModules()
 {
     //
     // At first, get active module IDs.
     //
     static $ret;
     if (isset($ret)) {
         return $ret;
     }
     $handler =& xoops_gethandler('module');
     $criteria = new CriteriaCompo();
     $criteria->add(new Criteria('isactive', 1));
     $criteria->add(new Criteria('hassearch', 1));
     // shortcut for speedup
     $db = $handler->db;
     $sort = $criteria->getSort();
     $sql = 'SELECT mid,name FROM ' . $db->prefix('modules') . ' ' . $criteria->renderWhere() . ($sort ? ' ORDER BY ' . $sort . ' ' . $criteria->getOrder() : ' ORDER BY weight ' . $criteria->getOrder() . ', mid ASC');
     $result = $db->query($sql);
     $handler =& xoops_gethandler('groupperm');
     $groupArr = Legacy_SearchUtils::getUserGroups();
     $ret = array();
     while (list($mid, $name) = $db->fetchRow($result)) {
         if ($handler->checkRight('module_read', $mid, $groupArr)) {
             $ret[] = array('mid' => $mid, 'name' => $name);
         }
     }
     return $ret;
 }
开发者ID:nunoluciano,项目名称:uxcl,代码行数:28,代码来源:LegacySearchService.class.php

示例2: array

 /**
  * Get a list of {@link SmartmediaFolder} objects for the search feature
  *
  * @param array $queryarray list of keywords to look for
  * @param string $andor specify which type of search we are performing : AND or OR
  * @param int $limit maximum number of results to return
  * @param int $offset at which folder shall we start
  * @param int $userid userid related to the creator of the folder
  *
  * @return array array containing information about the folders mathing the search criterias
  */
 function &getObjectsForSearch($queryarray = array(), $andor = 'AND', $limit = 0, $offset = 0, $userid = 0)
 {
     global $xoopsConfig;
     $ret = array();
     $sql = "SELECT item." . $this->_key_field . ", itemtext." . $this->_caption_field . ", itemtext.description, parent.categoryid FROM\r\n                   (\r\n        \t\t\t (" . $this->_db->prefix($this->_dbtable) . " AS item\r\n\t\t\t\t\t   INNER JOIN " . $this->_db->prefix($this->_dbtable) . "_text AS itemtext \r\n        \t\t       ON item." . $this->_key_field . " = itemtext." . $this->_key_field . "\r\n        \t\t     )\r\n        \t\t     INNER JOIN " . $this->_db->prefix($this->_dbtable_parent) . " AS parent\r\n         \t\t     ON parent." . $this->_key_field . " = item." . $this->_key_field . "\r\n                   )";
     if ($queryarray) {
         $criteriaKeywords = new CriteriaCompo();
         for ($i = 0; $i < count($queryarray); $i++) {
             $criteriaKeyword = new CriteriaCompo();
             $criteriaKeyword->add(new Criteria('itemtext.title', '%' . $queryarray[$i] . '%', 'LIKE'), 'OR');
             $criteriaKeyword->add(new Criteria('itemtext.description', '%' . $queryarray[$i] . '%', 'LIKE'), 'OR');
             $criteriaKeywords->add($criteriaKeyword, $andor);
         }
     }
     if ($userid != 0) {
         $criteriaUser = new CriteriaCompo();
         $criteriaUser->add(new Criteria('item.uid', $userid), 'OR');
     }
     $criteria = new CriteriaCompo();
     // Languageid
     $criteriaLanguage = new CriteriaCompo();
     $criteriaLanguage->add(new Criteria('itemtext.languageid', $xoopsConfig['language']));
     $criteria->add($criteriaLanguage);
     if (!empty($criteriaUser)) {
         $criteria->add($criteriaUser, 'AND');
     }
     if (!empty($criteriaKeywords)) {
         $criteria->add($criteriaKeywords, 'AND');
     }
     $criteria->setSort('item.weight');
     $criteria->setOrder('ASC');
     $sql .= ' ' . $criteria->renderWhere();
     //$sql .= "GROUP BY parent." . $this->_key_field . "";
     if ($criteria->getSort() != '') {
         $sql .= ' ORDER BY ' . $criteria->getSort() . '
             ' . $criteria->getOrder();
     }
     //echo "<br />$sql<br />";
     $result = $this->_db->query($sql, $limit, $offset);
     // If no records from db, return empty array
     if (!$result) {
         return $ret;
     }
     // Add each returned record to the result array
     while ($myrow = $this->_db->fetchArray($result)) {
         $item['id'] = $myrow[$this->_key_field];
         $item['title'] = $myrow[$this->_caption_field];
         $item['categoryid'] = $myrow[$this->_parent_field];
         $ret[] = $item;
         unset($item);
     }
     return $ret;
 }
开发者ID:trabisdementia,项目名称:xuups,代码行数:64,代码来源:folder.php


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