本文整理汇总了PHP中Category::count方法的典型用法代码示例。如果您正苦于以下问题:PHP Category::count方法的具体用法?PHP Category::count怎么用?PHP Category::count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Category
的用法示例。
在下文中一共展示了Category::count方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetModelCount
/**
* testGetModelCount
*
* Test for ERestBaseAction->getModelCount()
*/
public function testGetModelCount()
{
$category = new Category();
$count = $category->count();
$this->assertEquals($count, $this->baseAction->getModelCount(null));
$this->assertEquals(1, $this->baseAction->getModelCount(1));
}
示例2: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
$counts = array();
$counts['article_total'] = \Article::count();
$counts['category_total'] = \Category::count();
$counts['user_total'] = \User::count();
$counts['page_total'] = \Page::count();
return View::make('admin.index.index')->with('counts', $counts);
}
示例3: listCategory
public function listCategory()
{
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') : [];
$categories = Category::select('categories.id', 'categories.name', 'categories.description', 'categories.order_no', 'parent.name as parent_name', 'categories.active');
if (!empty($search)) {
foreach ($search as $key => $value) {
if (empty($value)) {
continue;
}
if ($key == 'active') {
if ($value == 'yes') {
$value = 1;
} else {
$value = 0;
}
$categories->where('categories.' . $key, $value);
} else {
if ($key == 'parent_id') {
$categories->where('categories.' . $key, '=', (int) $value);
} else {
$value = ltrim(rtrim($value));
$categories->where('categories.' . $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;
}
$categories->orderBy($columns[$column]['name'], $value['dir'] == 'asc' ? 'asc' : 'desc');
}
}
$count = $categories->count();
if ($length > 0) {
$categories = $categories->skip($start)->take($length);
}
$arrcategories = $categories->leftJoin('categories as parent', 'categories.parent_id', '=', 'parent.id')->get()->toArray();
$arrReturn = ['draw' => Input::has('draw') ? Input::get('draw') : 1, 'recordsTotal' => Category::count(), 'recordsFiltered' => $count, 'data' => []];
if (!empty($arrcategories)) {
foreach ($arrcategories as $category) {
$category['parent_name'] = is_null($category['parent_name']) ? 'No Parent' : $category['parent_name'];
$arrReturn['data'][] = [++$start, $category['id'], $category['name'], $category['description'], $category['order_no'], $category['parent_name'], $category['active']];
}
}
return $arrReturn;
}
示例4: get_index
public function get_index()
{
$admin = Auth::user();
$mp3s = MP3::orderBy('created_at', 'desc')->take(10)->get();
$mp3scount = MP3::count();
$mp4s = MP4::orderBy('created_at', 'desc')->take(10)->get();
$mp4scount = MP4::count();
$users = User::orderBy('created_at', 'desc')->take(10)->get();
$userscount = User::count();
$categories = Category::orderBy('name')->take(10)->get();
$catscount = Category::count();
$pages = Page::orderBy('created_at', 'desc')->paginate(10);
$pages_count = Page::count();
$title = 'Administrasyon';
return View::make('admin.index')->withAdmin($admin)->withMp3s($mp3s)->withMp4s($mp4s)->withUsers($users)->withCategories($categories)->withPages($pages)->withTitle($title)->withMp3sCount($mp3scount)->withMp4sCount($mp4scount)->withUsersCount($userscount)->withCatsCount($catscount)->withPagesCount($pages_count);
}
示例5: run
public function run()
{
if (Category::count('id')) {
echo 'Skipping category seeder' . "\n";
return;
}
$categories = DB::connection('old')->table('categories')->get();
DB::transaction(function () use($categories) {
foreach ($categories as $c) {
$cat = new Category();
$cat->position = $c->position;
$cat->state = $c->state;
$cat->title = $c->name;
$cat->about = $c->description;
$cat->icon = $c->image;
$cat->save();
}
});
}
示例6: test_post_count_delete
function test_post_count_delete()
{
$this->_assert_equals($this->m_all_count, Category::count());
}
示例7: slug
Notify::error($errors);
return Response::redirect('admin/categories/add');
}
if (empty($input['slug'])) {
$input['slug'] = $input['title'];
}
$input['slug'] = slug($input['slug']);
$category = Category::create($input);
Extend::process('category', $category->id);
Notify::success(__('categories.created'));
return Response::redirect('admin/categories');
});
/*
Delete Category
*/
Route::get('admin/categories/delete/(:num)', function ($id) {
$total = Category::count();
if ($total == 1) {
Notify::error(__('categories.delete_error'));
return Response::redirect('admin/categories/edit/' . $id);
}
// move posts
$category = Category::where('id', '<>', $id)->fetch();
// delete selected
Category::find($id)->delete();
// update posts
Post::where('category', '=', $id)->update(array('category' => $category->id));
Notify::success(__('categories.deleted'));
return Response::redirect('admin/categories');
});
});
示例8: Slug
<?php
$s = new Slug();
$slug_count = $s->like('id', 'category.', 'after')->count();
$c = new Category();
$content_count = $c->count();
if ($slug_count < $content_count) {
$slugs = array();
$c = new Category();
foreach ($c->select('slug')->get_iterated() as $content) {
$slugs[] = "('category." . $content->slug . "')";
}
$slugs = join(', ', $slugs);
$this->db->query("INSERT INTO {$s->table}(id) VALUES {$slugs} ON DUPLICATE KEY UPDATE id=id;");
}
$done = true;
示例9: blog_category_count
public function blog_category_count($args)
{
if ($sql = $this->include_exclude_blogs($args)) {
$blog_filter = 'and category_blog_id ' . $sql;
} elseif (isset($args['blog_id'])) {
$blog_id = intval($args['blog_id']);
$blog_filter = 'and category_blog_id = ' . $blog_id;
}
$where = "category_class = 'category'\n {$blog_filter}";
require_once 'class.mt_category.php';
$cat = new Category();
$result = $cat->count(array('where' => $where));
return $result;
}
示例10: validate
public function validate()
{
if ($this->category_id) {
if ($this->id) {
$rows = Category::count(array('conditions' => array('category_id = ? AND name = ? AND id <> ?', $this->category_id, $this->name, $this->id)));
} else {
$rows = Category::count(array('conditions' => array('category_id = ? AND name = ?', $this->category_id, $this->name)));
}
} else {
if ($this->id) {
$rows = Category::count(array('conditions' => array('category_id is null AND name = ? AND id <> ?', $this->name, $this->id)));
} else {
$rows = Category::count(array('conditions' => array('category_id is null AND name = ?', $this->name)));
}
}
if ($rows) {
$this->errors->add('name', "El nombre no es único en esta categoría");
} else {
return TRUE;
}
}
示例11: isset
$parent = isset($_GET['parent']) ? (int) $_GET['parent'] : 0;
if (isset($_GET['d'])) {
$d = (int) $_GET['d'];
if ($d > 0) {
Category::delete($d);
}
}
if (isset($_GET['o'])) {
$o = (int) $_GET['o'];
$r = (int) $_GET['r'];
if ($r != 0) {
$r = 1;
}
Category::set_order($o, $parent, $r);
}
$tct = Category::count(array('parent' => $parent));
//total count
$rpp = 10;
//row per page
$pager_options = array('mode' => 'Sliding', 'perPage' => $rpp, 'delta' => 2, 'totalItems' => $tct, 'urlVar' => "pageID{$parent}", 'excludeVars' => array('o', 'r', 'd', 't', 'e'));
$pager = @Pager::factory($pager_options);
list($from, $to) = $pager->getOffsetByPageId();
$categories = Category::get_all(array('r.parent' => $parent), '', $from - 1 . ", {$rpp}");
include "page-header.php";
?>
<div id="wrapper">
<?php
include "page-left.php";
?>
示例12: set_paginate_options
private function set_paginate_options($category_id = NULL)
{
$config = array();
if ($category_id) {
$config["base_url"] = site_url() . "categories/{$category_id}";
$config["total_rows"] = Category::count(array('conditions' => 'category_id = ' . $category_id . ''));
} else {
$config["base_url"] = site_url() . "categories";
$config["total_rows"] = Category::count(array('conditions' => 'category_id is null'));
}
$config["use_page_numbers"] = TRUE;
$config["per_page"] = 10;
$config["uri_segment"] = 3;
$config["first_link"] = "<< " . lang('web_first');
$config['first_tag_open'] = "<span class='pag'>";
$config['first_tag_close'] = '</span>';
$config['last_link'] = lang('web_last') . " >>";
$config['last_tag_open'] = "<span class='pag'>";
$config['last_tag_close'] = "</span>";
$config['next_link'] = FALSE;
$config['next_tag_open'] = "<span class='pag'>";
$config['next_tag_close'] = '</span>';
$config['prev_link'] = FALSE;
$config['prev_tag_open'] = "<span class='pag'>";
$config['prev_tag_close'] = '</span>';
$config['cur_tag_open'] = "<span class='pag pag_active'>";
$config['cur_tag_close'] = '</span>';
$config['num_tag_open'] = "<span class='pag'>";
$config['num_tag_close'] = '</span>';
$config['full_tag_open'] = "<div class='navigation'>";
$config['full_tag_close'] = '</div>';
$choice = $config["total_rows"] / $config["per_page"];
//$config["num_links"] = round($choice);
return $config;
}