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


PHP Model_Category::find_all方法代码示例

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


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

示例1: action_new

 public function action_new()
 {
     if (Auth::instance()->logged_in()) {
         $view = View::factory('topic/new');
         $category = new Model_Category();
         $category_id = $this->request->param('id');
         $view->categories = $category->find_all();
         $user_id = Auth::instance()->get_user()->pk();
         $view->role_id = ORM::factory('Roles_User')->get_last_role_id($user_id);
         $user_id = Auth::instance()->get_user()->pk();
         $users = ORM::factory('User')->get_data($user_id);
         $this->template->content = $view->render();
         if ($this->request->method() === Request::POST) {
             if (!Security::check($this->request->param('id'))) {
                 throw new Exception("Bad token!");
             }
             $title = $this->request->post('title');
             $category_id = $this->request->post('category_id');
             $author = $user_id;
             $content = $this->request->post('content');
             if (empty($title) or empty($category_id) or empty($author) or empty($content)) {
                 throw new Exception("Fields cannot be empty!");
             }
             $data = array('title' => $title, 'category_id' => $category_id, 'author_id' => $author, 'content' => $content, 'published' => time());
             $topic = new Model_Topic();
             $publish_topic = $topic->publish($data);
             if (!$publish_topic) {
                 throw new Exception("Cannot publish your topic!");
             }
             $this->request->redirect('category/index/' . $category_id);
         }
     } else {
         $this->redirect('');
     }
 }
开发者ID:reGative,项目名称:Phorumph,代码行数:35,代码来源:Topic.php

示例2: action_index

 public function action_index()
 {
     $cat = new Model_Category();
     $list_cat = $cat->find_all();
     // get all to print at sidebar view
     $loc = new Model_Location();
     $list_loc = $loc->find_all();
     // get all to print at sidebar view
     $user = Auth::instance()->get_user();
     $ads = new Model_Ad();
     Controller::$full_width = TRUE;
     $my_adverts = $ads->where('id_user', '=', $user->id_user);
     $res_count = $my_adverts->count_all();
     if ($res_count > 0) {
         $pagination = Pagination::factory(array('view' => 'oc-panel/crud/pagination', 'total_items' => $res_count, 'items_per_page' => core::config('advertisement.advertisements_per_page')))->route_params(array('controller' => $this->request->controller(), 'action' => $this->request->action()));
         Breadcrumbs::add(Breadcrumb::factory()->set_title(__('My ads'))->set_url(Route::url('oc-panel', array('controller' => 'myads', 'action' => 'index'))));
         Breadcrumbs::add(Breadcrumb::factory()->set_title(sprintf(__("Page %d"), $pagination->current_page)));
         $ads = $my_adverts->order_by('published', 'desc')->limit($pagination->items_per_page)->offset($pagination->offset)->find_all();
         $this->template->content = View::factory('oc-panel/profile/ads', array('ads' => $ads, 'pagination' => $pagination, 'category' => $list_cat, 'location' => $list_loc, 'user' => $user));
     } else {
         $this->template->content = View::factory('oc-panel/profile/ads', array('ads' => $ads, 'pagination' => NULL, 'category' => NULL, 'location' => NULL, 'user' => $user));
     }
 }
开发者ID:Chinese1904,项目名称:openclassifieds2,代码行数:23,代码来源:myads.php


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