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


PHP Model_Location::delete方法代码示例

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


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

示例1: _storeZip

 protected function _storeZip(Garp_Service_PostcodeNl_Zipcode &$zip, $key, $overwrite)
 {
     $model = new Model_Location();
     $select = $model->select()->where('zip = ? AND number IS NULL', $zip->zipcode);
     $existingRow = $model->fetchRow($select);
     if ($existingRow && $overwrite) {
         $model->delete('id = ' . $existingRow->id);
     }
     if (!$existingRow || $overwrite) {
         $this->_insertZip($zip, $model);
     }
     $this->_progress->advance();
     $this->_progress->display('Importing zip codes', '%s left');
 }
开发者ID:grrr-amsterdam,项目名称:garp3,代码行数:14,代码来源:PostcodeNl.php

示例2: action_delete

 /**
  * CRUD controller: DELETE
  */
 public function action_delete()
 {
     $this->auto_render = FALSE;
     $location = new Model_Location($this->request->param('id'));
     //update the elements related to that ad
     if ($location->loaded()) {
         //update all the siblings this location has and set the location parent
         $query = DB::update('locations')->set(array('id_location_parent' => $location->id_location_parent))->where('id_location_parent', '=', $location->id_location)->execute();
         //update all the ads this location has and set the location parent
         $query = DB::update('ads')->set(array('id_location' => $location->id_location_parent))->where('id_location', '=', $location->id_location)->execute();
         try {
             $location->delete();
             $this->template->content = 'OK';
             Alert::set(Alert::SUCCESS, __('Location deleted'));
         } catch (Exception $e) {
             Alert::set(Alert::ERROR, $e->getMessage());
         }
     } else {
         Alert::set(Alert::SUCCESS, __('Location not deleted'));
     }
     Request::current()->redirect(Route::url('oc-panel', array('controller' => 'location', 'action' => 'index')));
 }
开发者ID:Wildboard,项目名称:WbWebApp,代码行数:25,代码来源:location.php

示例3: action_delete

 /**
  * CRUD controller: DELETE
  */
 public function action_delete()
 {
     $this->auto_render = FALSE;
     $locations = array();
     if ($id_location = $this->request->param('id')) {
         $locations[] = $id_location;
     } elseif (core::post('locations')) {
         $locations = core::post('locations');
     }
     if (count($locations) > 0) {
         foreach ($locations as $id_location) {
             $location = new Model_Location($id_location);
             //update the elements related to that ad
             if ($location->loaded()) {
                 //check if the parent is loaded/exists avoiding errors, if doesnt exist to the root
                 $parent_loc = new Model_Location($location->id_location_parent);
                 if ($parent_loc->loaded()) {
                     $id_location_parent = $location->id_location_parent;
                 } else {
                     $id_location_parent = 1;
                 }
                 //update all the siblings this location has and set the location parent
                 $query = DB::update('locations')->set(array('id_location_parent' => $id_location_parent))->where('id_location_parent', '=', $location->id_location)->execute();
                 //update all the ads this location has and set the location parent
                 $query = DB::update('ads')->set(array('id_location' => $id_location_parent))->where('id_location', '=', $location->id_location)->execute();
                 try {
                     $location_name = $location->name;
                     $location->delete();
                     $this->template->content = 'OK';
                     //recalculating the deep of all the categories
                     $this->action_deep();
                     Core::delete_cache();
                     Alert::set(Alert::SUCCESS, sprintf(__('Location %s deleted'), $location_name));
                 } catch (Exception $e) {
                     Alert::set(Alert::ERROR, $e->getMessage());
                 }
             } else {
                 Alert::set(Alert::SUCCESS, __('Location not deleted'));
             }
         }
     }
     HTTP::redirect(Route::url('oc-panel', array('controller' => 'location', 'action' => 'index')));
 }
开发者ID:kotsios5,项目名称:openclassifieds2,代码行数:46,代码来源:location.php

示例4: action_delete

 /**
  * CRUD controller: DELETE
  */
 public function action_delete()
 {
     $this->auto_render = FALSE;
     $location = new Model_Location($this->request->param('id'));
     //update the elements related to that ad
     if ($location->loaded()) {
         //check if the parent is loaded/exists avoiding errors, if doesnt exist to the root
         $parent_loc = new Model_Location($location->id_location_parent);
         if ($parent_loc->loaded()) {
             $id_location_parent = $location->id_location_parent;
         } else {
             $id_location_parent = 1;
         }
         //update all the siblings this location has and set the location parent
         $query = DB::update('locations')->set(array('id_location_parent' => $id_location_parent))->where('id_location_parent', '=', $location->id_location)->execute();
         //update all the ads this location has and set the location parent
         $query = DB::update('ads')->set(array('id_location' => $id_location_parent))->where('id_location', '=', $location->id_location)->execute();
         //delete icon_delete
         $root = DOCROOT . 'images/locations/';
         //root folder
         if (is_dir($root)) {
             @unlink($root . $location->seoname . '.png');
             // delete icon from Amazon S3
             if (core::config('image.aws_s3_active')) {
                 $s3->deleteObject(core::config('image.aws_s3_bucket'), 'images/locations/' . $location->seoname . '.png');
             }
             // update location info
             $location->has_image = 0;
             $location->last_modified = Date::unix2mysql();
             $location->save();
         }
         try {
             $location->delete();
             $this->template->content = 'OK';
             //recalculating the deep of all the categories
             $this->action_deep();
             Core::delete_cache();
             Alert::set(Alert::SUCCESS, __('Location deleted'));
         } catch (Exception $e) {
             Alert::set(Alert::ERROR, $e->getMessage());
         }
     } else {
         Alert::set(Alert::SUCCESS, __('Location not deleted'));
     }
     HTTP::redirect(Route::url('oc-panel', array('controller' => 'location', 'action' => 'index')));
 }
开发者ID:nick-catanchin-ie,项目名称:openclassifieds2,代码行数:49,代码来源:location.php


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