本文整理匯總了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;
}