本文整理汇总了PHP中Configure::count方法的典型用法代码示例。如果您正苦于以下问题:PHP Configure::count方法的具体用法?PHP Configure::count怎么用?PHP Configure::count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Configure
的用法示例。
在下文中一共展示了Configure::count方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: listConfigure
public function listConfigure()
{
if (!Request::ajax()) {
return App::abort(404);
}
$start = Input::has('start') ? (int) Input::get('start') : 0;
$length = Input::has('length') ? Input::get('length') : 10;
$search = Input::has('search') ? Input::get('search') : [];
$configures = Configure::select('id', 'cname', 'ckey', 'cvalue', 'cdescription', 'active')->whereNotIn('ckey', ['title_site', 'meta_description', 'main_logo', 'favicon', 'mask'])->where('ckey', 'not like', 'email_%');
if (!empty($search)) {
foreach ($search as $key => $value) {
if (empty($value)) {
continue;
}
if ($key == 'active') {
if ($value == 'yes') {
$value = 1;
} else {
$value = 0;
}
$configures->where($key, $value);
} else {
$value = ltrim(rtrim($value));
$configures->where($key, 'like', '%' . $value . '%');
}
}
}
$order = Input::has('order') ? Input::get('order') : [];
if (!empty($order)) {
$columns = Input::has('columns') ? Input::get('columns') : [];
foreach ($order as $value) {
$column = $value['column'];
if (!isset($columns[$column]['name']) || empty($columns[$column]['name'])) {
continue;
}
$configures->orderBy($columns[$column]['name'], $value['dir'] == 'asc' ? 'asc' : 'desc');
}
}
$count = $configures->count();
if ($length > 0) {
$configures = $configures->skip($start)->take($length);
}
$arrConfigures = $configures->get()->toArray();
$arrReturn = ['draw' => Input::has('draw') ? Input::get('draw') : 1, 'recordsTotal' => Configure::count(), 'recordsFiltered' => $count, 'data' => []];
if (!empty($arrConfigures)) {
foreach ($arrConfigures as $configure) {
$arrReturn['data'][] = array(++$start, $configure['id'], $configure['cname'], $configure['ckey'], $configure['cvalue'], $configure['cdescription'], $configure['active']);
}
}
$response = Response::json($arrReturn);
$response->header('Content-Type', 'application/json');
return $response;
}