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


PHP Model_Category::api_filter方法代码示例

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


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

示例1: action_index

 /**
  * Handle GET requests.
  */
 public function action_index()
 {
     try {
         if (is_numeric($this->request->param('id'))) {
             $this->action_get();
         } else {
             $output = array();
             $cats = new Model_Category();
             //make a search with q? param
             if (isset($this->_params['q']) and strlen($this->_params['q'])) {
                 $cats->where_open()->where('name', 'like', '%' . $this->_params['q'] . '%')->or_where('description', 'like', '%' . $this->_params['q'] . '%')->where_close();
             }
             //filter results by param, verify field exists and has a value and sort the results
             $cats->api_filter($this->_filter_params)->api_sort($this->_sort);
             //how many? used in header X-Total-Count
             $count = $cats->count_all();
             $cats = $cats->cached()->find_all();
             //as array
             foreach ($cats as $category) {
                 $cat = $category->as_array();
                 //$cat['parents']  = $category->get_parents_ids();
                 //$cat['siblings'] = $category->get_siblings_ids();
                 $cat['icon'] = $category->get_icon();
                 $cat['price'] = i18n::money_format($category->price);
                 $output[] = $cat;
             }
             $this->rest_output(array('categories' => $output), 200, $count);
         }
     } catch (Kohana_HTTP_Exception $khe) {
         $this->_error($khe);
         return;
     }
 }
开发者ID:vericoms,项目名称:openclassifieds2,代码行数:36,代码来源:categories.php


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