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


PHP orm::facrtory方法代码示例

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


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

示例1: create

 /**
  * used to create a location, requires the hidden fields for the latatude and longatude.
  */
 public function create()
 {
     if ($this->access->allowed('locations', 'create')) {
         $input = Validation::factory($this->input->post())->pre_filter('trim')->add_rules('name', 'required')->add_rules('status', 'required')->add_rules('group', 'required')->add_rules('latitude', 'required')->add_rules('longitude', 'required')->add_rules('address', 'required');
         if ($input->validate()) {
             $location = orm::Factory('location');
             $location->name = $this->input->post('name');
             $location->description = $this->input->post('description');
             $location->url = $this->input->post('url');
             $location->status = $this->input->post('status');
             $location->group = $this->input->post('group');
             $location->order = orm::facrtory('location')->where('group', $this->input->post('group'))->count_all();
             $location->latitude = $this->input->post('latitude');
             $location->longitude = $this->input->post('longitude');
             $location->address = $this->input->post('address');
             $images = $this->input->post('images');
             $location->image = !is_null($images['logo']) ? $images['logo'] : 'logo.jpg';
             if ($location->save()) {
                 $this->notification->add($this->i18n['system.location.success'], $location->name);
                 $cms = DOCROOT . 'application/' . SITE . '/media/cms/locations/' . $location->id;
                 // this will create the folder
                 if (file::tree($cms)) {
                     $file = $location->image;
                     // if there was no image set, then use the default
                     if (isset($images)) {
                         $path = DOCROOT . 'upload/' . $location->image;
                         // use the uploaded file
                     } else {
                         $path = 'application/' . SITE . '/media/cms/locations/logo.jpg';
                     }
                     if (file_exists($path)) {
                         if (copy($path, $cms . '/' . $file)) {
                             $this->notification->add($this->i18n['cms.image.success']);
                         } else {
                             $this->notification->add($this->i18n['cms.image.error']);
                         }
                     } else {
                         $this->notification->add($this->i18n['cms.image.error']);
                     }
                 } else {
                     $this->notification->add($this->i18n['cms.folder.error']);
                 }
                 url::redirect(url::area() . 'edit/' . $location->id);
             } else {
                 $this->notification->add($this->i18n['system.location.error']);
             }
         } else {
             foreach ($input->errors() as $key => $value) {
                 $this->notification->add($this->i18n['filter.' . $key . '.' . $value]);
             }
         }
     }
     url::redirect(url::area() . 'add/');
     // name might not exist
 }
开发者ID:HIVE-Creative,项目名称:spicers,代码行数:58,代码来源:locations.php


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