本文整理汇总了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');
}
示例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')));
}
示例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')));
}
示例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')));
}