本文整理汇总了PHP中Model_Location::api_filter方法的典型用法代码示例。如果您正苦于以下问题:PHP Model_Location::api_filter方法的具体用法?PHP Model_Location::api_filter怎么用?PHP Model_Location::api_filter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model_Location
的用法示例。
在下文中一共展示了Model_Location::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();
$locs = new Model_Location();
//make a search with q? param
if (isset($this->_params['q']) and strlen($this->_params['q'])) {
$locs->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
$locs->api_filter($this->_filter_params)->api_sort($this->_sort);
//how many? used in header X-Total-Count
$count = $locs->count_all();
$locs = $locs->cached()->find_all();
//as array
foreach ($locs as $location) {
$loc = $location->as_array();
//$loc['siblings'] = $location->get_siblings_ids();
$loc['icon'] = $location->get_icon();
$output[] = $loc;
}
$this->rest_output(array('locations' => $output), 200, $count);
}
} catch (Kohana_HTTP_Exception $khe) {
$this->_error($khe);
return;
}
}