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


PHP orm类代码示例

本文整理汇总了PHP中orm的典型用法代码示例。如果您正苦于以下问题:PHP orm类的具体用法?PHP orm怎么用?PHP orm使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: view

 public function view($id, $parity)
 {
     // check to see if the user has access, this is in case we want to make it so that only logged in people can view lightboxes in the future, etc/.
     if ($this->access->allowed('lightboxes', 'read')) {
         $parity_field = 'name';
         // this is a  variable so that it can easily be changed in the future.
         $lightbox = orm::factory('lightbox')->find($id);
         // sanity check and parity check.
         if ($lightbox->loaded && $lightbox->{$parity_field} == url::decode($parity)) {
             // The only times that a lightbox are viewable are when it is public or the current user is the owner. 	A status of approved = public, a status of pending = private
             if ($lightbox->status == 'approved' || $this->user && $this->user->id == $lightbox->creator_id) {
                 $view = new view(url::routes_area() . 'view');
                 // add one to the views for the lightbox.
                 $lightbox->views += 1;
                 $lightbox->save(false);
                 $view->lightbox = $lightbox;
                 $view->is_owner = $this->user && $this->user->id == $lightbox->creator_id;
                 $view->current_user = $this->current;
                 $this->breadcrumbs->add()->url(url::current())->title($lightbox->name);
                 $view->breadcrumbs = $this->breadcrumbs->get();
                 $this->breadcrumbs->delete();
                 $this->template->content = $view;
             } else {
                 $this->notification->add($this->i18n['system.lightbox.status']);
                 url::redirect('account');
             }
         } else {
             $this->notification->add($this->i18n['system.lightbox.invalid']);
             url::redirect('account');
         }
     } else {
         $this->notification->add($this->i18n['system.lightbox.login']);
         url::redirect('account');
     }
 }
开发者ID:HIVE-Creative,项目名称:spicers,代码行数:35,代码来源:lightboxes.php

示例2: index

 /**
  * Used to display the index page but also uses a jquery and the pagination to do preload of next pages
  * of the news articles. Which are then displaye don scroll 
  * @param integer $page the page number  (Matt are you sure this is needed, the pagination is smart enough not to need this). 
  */
 public function index($page = 1)
 {
     $total = orm::factory('news')->where('group', 'site')->where('status', 'approved')->count_all();
     $paging = new Pagination(array('total_items' => $total, 'items_per_page' => 3));
     $articles = orm::factory('news')->where('group', 'site')->where('status', 'approved')->find_all($paging->items_per_page, $paging->sql_offset);
     $view = new View(url::location());
     $view->articles = $articles;
     $view->pagination = $paging->render();
     $view->page_number = $paging->page_number();
     // If the request is an ajax request, then the page is attempting to autoupdate
     // the items with in the news, so just send through the news items.
     if (request::is_ajax()) {
         // if the ajax is attempting to get a page which doesnt exist, send 404
         if ($page > $paging->total_pages) {
             Event::run('system.404');
         } else {
             $this->ajax['view'] = $view;
         }
     } else {
         // otherwise its a http request, send throught he entire page with template.
         $this->template->title = 'About Us › News & Updates Archive';
         $this->breadcrumbs->add()->url(false)->title('Archive');
         $view->breadcrumbs = $this->breadcrumbs->cut();
         $this->template->content = $view;
     }
 }
开发者ID:HIVE-Creative,项目名称:spicers,代码行数:31,代码来源:archive.php

示例3: index

 public function index()
 {
     $view = new View(url::location());
     $view->articles = orm::factory('news')->where('group', 'site')->where('status', 'approved')->find_all(6);
     $this->template->title = 'About Us › News & Updates';
     $this->template->content = $view;
 }
开发者ID:HIVE-Creative,项目名称:spicers,代码行数:7,代码来源:news.php

示例4: index

 public function index()
 {
     $view = new View(url::location());
     $this->template->title = 'About Us › Global Alliances';
     $view->breadcrumbs = $this->breadcrumbs->cut();
     $view->locations = orm::factory('location')->where('status', 'approved')->where('group', 'alliances')->find_all();
     $this->template->content = $view;
 }
开发者ID:HIVE-Creative,项目名称:spicers,代码行数:8,代码来源:alliances.php

示例5: delete

 /**
  * Simple delete of the object, plus a call to the unify to check to see if the 
  * collection also needs to be deleted. 
  * @return boolean $return, whether or not  the call did everything expected
  */
 public function delete()
 {
     $original = orm::factory('pigment', $this->id);
     $return = parent::delete();
     if ($return) {
         $return = $this->unify($original);
     }
 }
开发者ID:HIVE-Creative,项目名称:spicers,代码行数:13,代码来源:pigment.php

示例6: glossary

 public function glossary()
 {
     $view = new View(url::location());
     $this->template->title = 'Environmental › Glossary';
     $this->breadcrumbs->add()->url(false)->title('Glossary');
     $view->breadcrumbs = $this->breadcrumbs->cut();
     $view->glossaries = orm::factory('glossary')->where('status', 'approved')->find_all();
     $this->template->content = $view;
 }
开发者ID:HIVE-Creative,项目名称:spicers,代码行数:9,代码来源:environmental.php

示例7: delete

 /**
  * Simple delete of the object, plus a call to the unify to check to see if the 
  * pigment also needs to be deleted. 
  * @return boolean $return, whether or not  the call did everything expected
  */
 public function delete()
 {
     $original = orm::factory('sheet', $this->id);
     $return = parent::delete();
     // if it was deleted, then verfiy
     if ($return) {
         $return = $this->unify($original);
     }
     return $return;
 }
开发者ID:HIVE-Creative,项目名称:spicers,代码行数:15,代码来源:sheet.php

示例8: index

 public function index()
 {
     $this->breadcrumbs->delete();
     $this->template->title = 'Home';
     $view = new view('home/index');
     $view->inspirations = orm::factory('inspiration')->where('status', 'approved')->find_all();
     $view->billboards = orm::factory('billboard')->where('status', 'approved')->find_all();
     $view->populars = orm::factory('paper')->where('status', 'approved')->where('popular', 'true')->orderby(NULL, 'RAND()')->find_all(8);
     $view->news = orm::factory('news')->where('group', 'site')->where('status', 'approved')->find_all(3);
     $this->template->content = $view;
 }
开发者ID:HIVE-Creative,项目名称:spicers,代码行数:11,代码来源:home.php

示例9: set

 public function set($name)
 {
     $feature = orm::factory('feature')->where('name', $name)->find();
     if ($feature->loaded) {
         return $feature;
     } else {
         $this->name = $name;
         parent::save();
         return $this;
     }
 }
开发者ID:HIVE-Creative,项目名称:spicers,代码行数:11,代码来源:feature.php

示例10: set

 public function set($name)
 {
     $tip = orm::factory('tip')->where('name', $name)->find();
     if ($tip->loaded) {
         return $tip;
     } else {
         $this->name = $name;
         parent::save();
         return $this;
     }
 }
开发者ID:HIVE-Creative,项目名称:spicers,代码行数:11,代码来源:tip.php

示例11: add

 /**
  * This will call the parentxontent controller to populate the view, while sending throught he type of content that it is 
  * as well as the paper_id, which will be used to autocomplete the paper combo box withg the correct result. 
  * @see Content_Controller::add()
  */
 public function add($paper_id = NULL)
 {
     $paper = orm::factory('paper', $paper_id);
     // load the paper so that we can get all the details required to populate the breadrumbs
     if ($paper->loaded) {
         $this->breadcrumbs->add()->url('products/papers/edit/' . url::encode($paper->name))->title(url::decode($paper->name));
         $this->breadcrumbs->add()->url('products/papers/technicals/index/' . $paper->id)->title('Technicals');
         $this->breadcrumbs->add()->url(false)->title('Add');
     }
     parent::add('technical', $paper->id);
 }
开发者ID:HIVE-Creative,项目名称:spicers,代码行数:16,代码来源:technicals.php

示例12: get

 /**
  * Create as we need to build the paper name if one doesnt exist. 
  */
 public function get()
 {
     $results = parent::get();
     // we have the results, we now need to go through and build the names up
     for ($i = 0; $i < count($results); $i++) {
         if ($results[$i]['name'] == NULL) {
             $collection = orm::factory('collection')->find($results[$i]['collection_id']);
             $results[$i]['name'] = $collection->paper->name . ' ' . $collection->finish->name . ' ' . ucwords($results[$i]['color']);
         }
     }
     return $results;
 }
开发者ID:HIVE-Creative,项目名称:spicers,代码行数:15,代码来源:Search_Pigments.php

示例13: calculate_total

 public function calculate_total()
 {
     $price = orm::factory('dish', $this->dish_id)->price;
     $temp = $this->get_ingredients_in_order_dish();
     foreach ($temp as $ingred) {
         $price += $ingred->price;
     }
     $temp = $this->get_subs_in_order_dish();
     foreach ($temp as $sub) {
         $price += $sub->price;
     }
     $this->price = $price;
     $this->save();
 }
开发者ID:nemni8,项目名称:Munch,代码行数:14,代码来源:ordersdish.php

示例14: action_add

 public function action_add($ordersdish_id, $ingredient_id, $price = NULL)
 {
     $ordersdishesingredient = ORM::factory('ordersdishesingredient');
     $ordersdishesingredient->orders_dishes_id = $ordersdish_id;
     $ordersdishesingredient->ingredient_id = $ingredient_id;
     if (!$price) {
         $dish_id = orm::factory('ordersdish', $ordersdish_id)->dish_id;
         $temp = orm::factory('dishesingredient')->where('dish_id', '=', $dish_id)->and_where('ingredient_id', '=', $ingredient_id)->find();
         $ordersdishesingredient->price = $temp->price;
     } else {
         $ordersdishesingredient->price = $price;
     }
     $ordersdishesingredient->save();
 }
开发者ID:nemni8,项目名称:Munch,代码行数:14,代码来源:ordersdishesingredient.php

示例15: action_add

 public function action_add($ordersdish_id, $group_id, $sub_id, $price = NULL)
 {
     $ordersdishesgroupssub = ORM::factory('ordersdishesgroupssub');
     $ordersdishesgroupssub->orders_dishes_id = $ordersdish_id;
     $ordersdishesgroupssub->group_id = $group_id;
     $ordersdishesgroupssub->sub_id = $sub_id;
     if (!$price) {
         $sub = orm::factory('sub')->where('group_id', '=', $group_id)->and_where('sub_id', '=', $sub_id)->find();
         $group_price = orm::factory('group', $group_id)->price;
         $ordersdishesgroupssub->price = $sub->price > 0 ? $sub->price : $group_price;
     } else {
         $ordersdishesgroupssub->price = $price;
     }
     $ordersdishesgroupssub->save();
 }
开发者ID:nemni8,项目名称:Munch,代码行数:15,代码来源:ordersdishesgroupssub.php


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