本文整理汇总了PHP中Json::response方法的典型用法代码示例。如果您正苦于以下问题:PHP Json::response方法的具体用法?PHP Json::response怎么用?PHP Json::response使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Json
的用法示例。
在下文中一共展示了Json::response方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: do_auth
public function do_auth()
{
$email = $this->request->post('email');
$password = $this->request->post('password');
$remember = $this->request->post('remember');
$return = $this->request->post('return') ? $this->request->post('return') : '/ariol-admin';
Auth::instance()->login($email, $password, $remember);
if (Auth::instance()->logged_in() && Auth::instance()->get_user()->roles == 1) {
Json::response(array('status' => 1, 'return' => $return));
} else {
$this->do_logout();
Json::response(array('status' => 2));
}
}
示例2: action_get_grid_data
public function action_get_grid_data()
{
$model = ORM::factory($this->_model);
$this->template->unSortableFields = $model->getUnSortableSortableFields();
$offset = Arr::get($_REQUEST, 'iDisplayStart');
$limit = Arr::get($_REQUEST, 'iDisplayLength');
$draw = intval(Arr::get($_REQUEST, 'sEcho'));
$sorting = Arr::get($_REQUEST, 'sSortDir_0');
$sortingColumn = $model->getColumnByNumber(arr::get($_REQUEST, 'iSortCol_0'));
$model = $this->before_fetch($model);
$clone = clone $model;
if ($sorting && $sortingColumn) {
$model = $model->order_by($sortingColumn, $sorting);
} else {
$model = $model->order_by('id', 'DESC');
}
$data = $model->offset($offset)->limit($limit)->find_all()->as_array();
$json_data = array('aaData' => array(), 'sEcho' => $draw, 'iTotalRecords' => count($data), 'iTotalDisplayRecords' => $clone->count_all());
foreach ($data as $index => $item) {
$json_data['aaData'][$index][] = '<input name="ids[]" value="' . $item->id . '" type="checkbox" class="checkbox" />';
foreach ($item->grid_fields() as $field => $attributes) {
$json_data['aaData'][$index][] = $item->grid_value($field);
}
}
Json::response($json_data);
}