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


PHP DB_Helper::orderBy方法代码示例

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


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

示例1: getListing

 /**
  * Method used to get the list of changes made against a specific issue.
  *
  * @param   integer $iss_id The issue ID
  * @param   string $order_by The order to sort the history
  * @return  array The list of changes
  */
 public static function getListing($iss_id, $order_by = 'DESC')
 {
     $order_by = DB_Helper::orderBy($order_by);
     $stmt = "SELECT\n                    *\n                 FROM\n                    {{%issue_history}},\n                    {{%history_type}}\n                 WHERE\n                    htt_id = his_htt_id AND\n                    his_is_hidden != 1 AND\n                    his_iss_id=? AND\n                    his_min_role <= ?\n                 ORDER BY\n                    his_id {$order_by}";
     $params = array($iss_id, Auth::getCurrentRole());
     try {
         $res = DB_Helper::getInstance()->getAll($stmt, $params);
     } catch (DbException $e) {
         return '';
     }
     foreach ($res as &$row) {
         $row['his_summary'] = Misc::processTokens(ev_gettext($row['his_summary']), $row['his_context']);
     }
     return $res;
 }
开发者ID:dabielkabuto,项目名称:eventum,代码行数:22,代码来源:class.history.php

示例2: getEmailListing

 /**
  * Method used to get the list of emails to be displayed in the
  * grid layout.
  *
  * @param   array $options The search parameters
  * @param   integer $current_row The current page number
  * @param   integer $max The maximum number of rows per page
  * @return  array The list of issues to be displayed
  */
 public static function getEmailListing($options, $current_row = 0, $max = 5)
 {
     $prj_id = Auth::getCurrentProject();
     if ($max == 'ALL') {
         $max = 9999999;
     }
     $start = $current_row * $max;
     $stmt = 'SELECT
                 sup_id,
                 sup_ema_id,
                 sup_iss_id,
                 sup_customer_id,
                 sup_from,
                 sup_date,
                 sup_to,
                 sup_subject,
                 sup_has_attachment
              FROM
                 (
                 {{%support_email}},
                 {{%email_account}}';
     if (!empty($options['keywords'])) {
         $stmt .= ', {{%support_email_body}} ';
     }
     $stmt .= '
                 )
                 LEFT JOIN
                     {{%issue}}
                 ON
                     sup_iss_id = iss_id';
     $stmt .= self::buildWhereClause($options);
     $stmt .= '
              ORDER BY
                 ' . Misc::escapeString($options['sort_by']) . ' ' . DB_Helper::orderBy($options['sort_order']);
     $total_rows = Pager::getTotalRows($stmt);
     $stmt .= '
              LIMIT
                 ' . Misc::escapeInteger($max) . ' OFFSET ' . Misc::escapeInteger($start);
     try {
         $res = DB_Helper::getInstance()->getAll($stmt);
     } catch (DbException $e) {
         return array('list' => '', 'info' => '');
     }
     if (count($res) < 1 && $current_row > 0) {
         // if there are no results, and the page is not the first page reset page to one and reload results
         Auth::redirect("emails.php?pagerRow=0&rows={$max}");
     }
     if (CRM::hasCustomerIntegration($prj_id)) {
         $crm = CRM::getInstance($prj_id);
         $customer_ids = array();
         foreach ($res as $row) {
             if (!empty($row['sup_customer_id']) && !in_array($row['sup_customer_id'], $customer_ids)) {
                 $customer_ids[] = $row['sup_customer_id'];
             }
         }
         if (count($customer_ids) > 0) {
             $company_titles = $crm->getCustomerTitles($customer_ids);
         }
     }
     foreach ($res as &$row) {
         $row['sup_subject'] = Mime_Helper::fixEncoding($row['sup_subject']);
         $row['sup_from'] = implode(', ', Mail_Helper::getName($row['sup_from'], true));
         if (empty($row['sup_to']) && !empty($row['sup_iss_id'])) {
             $row['sup_to'] = 'Notification List';
         } else {
             $to = Mail_Helper::getName($row['sup_to']);
             // Ignore unformattable headers
             if (!Misc::isError($to)) {
                 $row['sup_to'] = Mime_Helper::fixEncoding($to);
             }
         }
         if (CRM::hasCustomerIntegration($prj_id)) {
             // FIXME: $company_titles maybe used uninitialied
             $row['customer_title'] = $company_titles[$row['sup_customer_id']];
         }
     }
     $total_pages = ceil($total_rows / $max);
     $last_page = $total_pages - 1;
     return array('list' => $res, 'info' => array('current_page' => $current_row, 'start_offset' => $start, 'end_offset' => $start + count($res), 'total_rows' => $total_rows, 'total_pages' => $total_pages, 'previous_page' => $current_row == 0 ? '-1' : $current_row - 1, 'next_page' => $current_row == $last_page ? '-1' : $current_row + 1, 'last_page' => $last_page));
 }
开发者ID:dabielkabuto,项目名称:eventum,代码行数:89,代码来源:class.support.php


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