当前位置: 首页>>代码示例>>PHP>>正文


PHP Category::select方法代码示例

本文整理汇总了PHP中Category::select方法的典型用法代码示例。如果您正苦于以下问题:PHP Category::select方法的具体用法?PHP Category::select怎么用?PHP Category::select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Category的用法示例。


在下文中一共展示了Category::select方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getCategoryTree

 static function getCategoryTree($db, $selected_id = null)
 {
     if (isset(Category::$cache_tree)) {
         $tree_root = Category::$cache_tree;
     } else {
         $all = Category::select($db, 'viewCategories', null, null, null, null, 'category_name');
         $tree_root = new Category();
         $tree_root->data['category_name'] = 'MENU';
         $tree_root->is_on_selected_path = true;
         while (count($all) > 0) {
             foreach ($all as $i => $c) {
                 $parent = null;
                 if ($c->ival('category_parent_id') == null) {
                     $parent = $tree_root;
                 } else {
                     $parent = $tree_root->findInChildren($c->ival('category_parent_id'));
                 }
                 if (isset($parent)) {
                     $parent->addChild($c);
                     unset($all[$i]);
                 }
             }
         }
         Category::$cache_tree = $tree_root;
     }
     if (isset($selected_id)) {
         $sc = $tree_root->findInChildren($selected_id);
         $sc->is_selected = true;
         $sc->setSelectedPath();
     }
     return $tree_root;
 }
开发者ID:lotcz,项目名称:zshop,代码行数:32,代码来源:category.m.php

示例2: edit

 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $p_id = Category::select('*')->where('p_id', '=', 0)->get();
     $category = Category::find($id);
     if (is_null($category)) {
         return Redirect::route('admin-category.index');
     }
     return View::make('backend.category.edit', compact('category', 'p_id'));
 }
开发者ID:huuson94,项目名称:btlwebapp,代码行数:15,代码来源:CategoriesController.php

示例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;
 }
开发者ID:nguyendaivu,项目名称:imagestock,代码行数:56,代码来源:CategoriesController.php

示例4: page

 /**
  * page() - handles displaying categories
  * @param string $path - the unique path column from the database
  * @return View
  */
 public function page($path = '/')
 {
     // Attempting to find a category corresponding to the given path
     try {
         $this->data['category'] = Category::select('id', 'title', 'slug', 'path')->where('path', $path)->firstOrFail();
     } catch (Exception $e) {
         App::abort(404);
     }
     $id = $this->data['category']->id;
     // If something found, search for contents
     if (count($id)) {
         $this->data['order'] = Input::get('sort');
         // $by = (Input::get('by') !== null) ? Input::get('by') : 'asc';
         if (Input::get('by') == 'asc') {
             $this->data['by'] = 'desc';
         } elseif (Input::get('by') == 'desc') {
             $this->data['by'] = 'asc';
         } else {
             $this->data['by'] = 'desc';
         }
         $this->data['contents'] = Content::select('id', 'title', 'slug', 'hits', 'created_at', 'created_by_alias')->where('catid', $id)->where('state', 1)->Order($this->data['order'], $this->data['by'])->paginate(40)->appends(Input::only('sort', 'by'));
         // Let's find our where are exactly in the tree structure of the categories
         //$node = Category::find($id, array('id', 'title', 'slug', 'path', '_lft', '_rgt'));
         $node = Category::getCategory($id);
         $this->data['descendants'] = $node->getDescendants(array('id', 'title', 'slug', 'path'));
         $this->data['ancestors'] = $node->ancestorsOf($id)->get();
         // First item is always root, but 'Начало' looks better, doesn't it?
         $this->data['ancestors'][0]->title = 'Начало';
         // Just to make the active highlight for the menus
         $this->data['active'] = $id;
         // Prepare data intended to go within the head tags
         $this->data['page_title'] = ucfirst($this->data['category']->title);
         foreach ($this->data['ancestors'] as $k => $v) {
             // first key (0) will generate the keyword 'начало', nobody needs this!
             if ($k != 0) {
                 $this->data['page_keywords'] .= $v->title . ', ';
             }
         }
         return View::make('home.page', $this->data);
     }
     return Redirect::to('/');
 }
开发者ID:hristodinev,项目名称:site,代码行数:47,代码来源:HomeController.php

示例5: update

 /**
  * 返回更新国家信息
  * @access public
  */
 function update()
 {
     $id = get_post_value('id');
     $field = array('category_1_id', 'category_2_id', 'category_2_cn', 'category_2_th', 'orders', 'status', 'created', 'created_name', 'audit_name', 'category_2_url');
     $m = new Category();
     $m->clear();
     $m->setField($field);
     $m->setTable('vcb_product_category_2');
     $m->setWhere('status', '!=', '60000');
     $m->setWhere('category_2_id', '=', $id);
     $m->setOrderBy('orders');
     $data = $m->select();
     $this->assign('data', $data);
 }
开发者ID:koery,项目名称:Vcanbuy,代码行数:18,代码来源:Category2Controller.class.php

示例6: 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;
开发者ID:Atomox,项目名称:benhelmerphotography,代码行数:16,代码来源:0022.php

示例7: foreach

 function build_autos($items, $data, $user)
 {
     foreach ($items as $index => &$item) {
         if (isset($item['auto'])) {
             if (isset($data['urls'][$item['auto']])) {
                 $item['path'] = $data['urls'][$item['auto']];
             } else {
                 if ($item['auto'] === 'set') {
                     $item['path'] = '';
                 }
             }
             if ($item['auto'] === 'profile') {
                 switch ($item['id']) {
                     case 'twitter':
                         $item['path'] = 'https://twitter.com/' . $user->twitter;
                         break;
                     default:
                         $item['path'] = $user->{$item['id']};
                         if (empty($item['path'])) {
                             unset($items[$index]);
                             continue;
                         }
                         break;
                 }
                 if (!isset($item['label']) || empty($item['label'])) {
                     $item['label'] = ucwords($item['id']) . ($item['id'] === 'google' ? '+' : '');
                 }
             } else {
                 if ($item['auto'] === 'rss') {
                     $item['path'] = '/feed/' . $item['id'] . ($item['id'] === 'essay' ? 's' : '') . '/recent.rss';
                     if (!isset($item['label'])) {
                         $item['label'] = $data['url_data'][$item['id']]['plural'] . ' RSS';
                     }
                 } else {
                     if (preg_match('/s$/', $item['auto']) || $item['auto'] === 'timeline') {
                         if ($item['auto'] === 'timeline' && isset($item['year'])) {
                             $item['path'] .= $item['year'] . '/';
                             if (isset($item['month']) && $item['month'] !== false && $item['month'] !== 'any') {
                                 $m = str_pad($item['month'], 2, '0', STR_PAD_LEFT);
                                 $item['path'] .= $m . '/';
                             }
                         }
                         if (strpos($item['auto'], '_') !== false) {
                             foreach (array('id', 'slug', 'month', 'year', 'day') as $id) {
                                 if ($id === 'month') {
                                     if (!isset($item['month']) || $item['month'] === 'any' || $item['month'] === false) {
                                         $item['month'] = '';
                                     } else {
                                         $item['month'] = str_pad($item['month'], 2, '0', STR_PAD_LEFT);
                                     }
                                 }
                                 if ($id === 'day' && !isset($item['day'])) {
                                     $item['day'] = '';
                                 }
                                 if ($id === 'slug' && !isset($item['slug']) && isset($item['id'])) {
                                     if (strpos($item['auto'], 'tag_') === 0) {
                                         $item['slug'] = $item['id'];
                                     } else {
                                         $c = new Category();
                                         if (is_numeric($item['id'])) {
                                             $c->select('slug')->get_by_id($item['id']);
                                             $item['slug'] = $c->slug;
                                         } else {
                                             $item['slug'] = $item['id'];
                                         }
                                     }
                                 }
                                 if (isset($item[$id])) {
                                     $item['path'] = str_replace(":{$id}", $item[$id], $item['path']);
                                 }
                             }
                         } else {
                             if (!isset($item['label'])) {
                                 $item['label'] = $data['url_data'][$item['auto'] === 'categories' ? 'category' : rtrim($item['auto'], 's')]['plural'];
                             }
                         }
                     } else {
                         if ($item['auto'] === 'home') {
                             if (!isset($item['label'])) {
                                 $item['label'] = $data['url_data']['home'];
                             }
                             $item['path'] = '/home/';
                         } else {
                             if ($item['auto'] === 'album' || $item['auto'] === 'set') {
                                 $a = new Album();
                                 $a->select('id,slug,created_on,title');
                                 if (is_numeric($item['id'])) {
                                     $a->where('id', $item['id']);
                                 } else {
                                     $a->where('slug', $item['id'])->or_where('internal_id', $item['id']);
                                 }
                                 $a->get();
                                 if (!$a->exists()) {
                                     unset($items[$index]);
                                     continue;
                                 }
                                 $item['path'] = str_replace(':id', $a->id, $item['path']);
                                 $item['path'] = str_replace(':slug', $a->slug, $item['path']);
                                 $item['path'] = str_replace(':year', date('Y', $a->created_on), $item['path']);
                                 $item['path'] = str_replace(':month', date('m', $a->created_on), $item['path']);
//.........这里部分代码省略.........
开发者ID:Caldis,项目名称:htdocs,代码行数:101,代码来源:sites.php

示例8: array

 /**
  *保存增加的三级目录数据
  * @access public
  */
 function add_saveCategory3()
 {
     $category_3_cn = get_post_value('category_3_cn');
     $category_3_th = get_post_value('category_3_th');
     $category_3_url = get_post_value('category_3_url');
     $category_2_id = get_post_value('category_2_id');
     $category_1_id = get_post_value('category_1_id');
     $orders = get_post_value('order');
     if (!$this->verifyCategory3()) {
         echo '<br> ' . $category_3_cn . ' 已存在,请核对后重新输入。<a href="javascript:history.go(-1)">返回</a><br>';
         return;
     }
     $field = array('category_1_cn', 'category_1_th');
     $m = new Category();
     $m->clear();
     $m->setTable('vcb_product_category_1');
     $m->setField($field);
     $m->setWhere('category_1_id', '=', $category_1_id);
     $dataCategory1 = $m->select();
     print_r($dataCategory1);
     $field = array('category_2_cn', 'category_2_th');
     $m->clear();
     $m->setTable('vcb_product_category_2');
     $m->setField($field);
     $m->setWhere('category_2_id', '=', $category_2_id);
     $dataCategory2 = $m->select();
     print_r($dataCategory2);
     $category_1_cn = $dataCategory1[0]['category_1_cn'];
     $category_1_th = $dataCategory1[0]['category_1_th'];
     $category_2_cn = $dataCategory2[0]['category_2_cn'];
     $category_2_th = $dataCategory2[0]['category_2_th'];
     $field = array('category_1_id' => $category_1_id, 'category_1_cn' => trim($category_1_cn), 'category_1_th' => trim($category_1_th), 'category_2_id' => $category_2_id, 'category_2_cn' => trim($category_2_cn), 'category_2_th' => trim($category_2_th), 'category_3_cn' => trim($category_3_cn), 'category_3_th' => trim($category_3_th), 'category_3_url' => trim($category_3_url), 'orders' => $orders, 'status' => '10000');
     $m->clear();
     $m->setTable('vcb_product_category_3');
     $m->setField($field);
     $data = $m->insert();
     if (!$data) {
         echo '<br>保存失败<br>';
     } else {
         echo '<br>保存成功,<a href="addCategory3">继续添加</a>,<a href="category3">返回</a><br>';
     }
 }
开发者ID:koery,项目名称:Vcanbuy,代码行数:46,代码来源:CategoryController.class.php

示例9: update

 /**
  * 返回更新国家信息
  * @access public
  */
 function update()
 {
     $id = get_post_value('id');
     $field = array('category_2.category_1_id', 'category_2.category_2_id', 'category_2.category_2_cn', 'category_2.category_2_th', 'category_3.category_3_id', 'category_3.category_3_cn', 'category_3.category_3_th', 'category_3.category_3_url', 'category_3.orders', 'category_3.status', 'category_3.created', 'category_3.created_name', 'category_3.audit_name', 'category_3.start_time', 'category_3.end_time');
     $m = new Category();
     $m->clear();
     $m->setField($field);
     $m->setTable('vcb_product_category_3 AS category_3');
     $m->setJoin('vcb_product_category_2 as category_2', 'category_2.category_2_id=category_3.category_2_id');
     $m->setWhere('category_3.status', '!=', '60000');
     $m->setWhere('category_3.category_3_id', '=', $id);
     $data = $m->select();
     $this->assign('data', $data);
     $data = $m->getCategory_2($data[0]['category_1_id']);
     $this->assign('category_2', $data);
 }
开发者ID:koery,项目名称:Vcanbuy,代码行数:20,代码来源:Category3Controller.class.php

示例10: Category

<?php

///////////////////////////////////
require 'tables.php';
if (isset($_GET['categoryName'])) {
    $category_new = $_GET['categoryName'];
    $Categorys = new Category();
    $Categorys->categoryName = $category_new;
    $Categorys->insert();
}
$Categorys = new Category();
$data = $Categorys->select();
$response = json_encode($data);
echo $response;
开发者ID:smagdy,项目名称:PHPproject,代码行数:14,代码来源:allCategory.php

示例11: getListNoteServer

 public function getListNoteServer($userId, $skip, $lastedUpdate)
 {
     if (is_null($lastedUpdate)) {
         return Category::select('note.noteId', 'note.noteMean', 'note.noteName', 'note.cateId', 'note.type', 'note.updated_at', 'note.idx')->where('userId', $userId)->join('note', 'note.cateId', '=', 'category.categoryId')->skip($skip)->take(100)->get();
     } else {
         return Category::select('note.noteId', 'note.noteMean', 'note.noteName', 'note.cateId', 'note.type', 'note.updated_at', 'note.idx')->where('userId', $userId)->join('note', 'note.cateId', '=', 'category.categoryId')->where('note.updated_at', '>', $lastedUpdate)->skip($skip)->take(100)->get();
     }
 }
开发者ID:nguyensonghao,项目名称:api,代码行数:8,代码来源:Note.php

示例12: getAllNodes

 public static function getAllNodes()
 {
     return Category::select('categories.id as id', 'categories.title as title', 'category_types.title as type')->withoutRoot('id', 'title', 'slug')->withDepth()->join('category_types', 'categories.type', '=', 'category_types.type')->get();
 }
开发者ID:hristodinev,项目名称:site,代码行数:4,代码来源:Category.php


注:本文中的Category::select方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。