/** * * @param type $id */ public function delete($id) { try { $this->repository->delete($id); } catch (\Exception $e) { return ['error' => 'true', 'messege' => "Produto não encontrado!"]; } }
/** * Generic method to delete any album * * @param type $id * * @return type */ function delete($id) { /* action to perform any task befor deleting an album */ do_action('rtmedia_before_delete_album', $this); /** * First fetch all the media from that album */ add_filter('rt_db_model_per_page', array($this, 'set_queries_per_page'), 10, 2); $page = 1; $flag = true; /** * Delete each media from the album first */ while ($media = $this->media->model->get_by_album_id($id, $page)) { $media_id = $media['result'][0]['media_id']; $flag = wp_delete_attachment($media_id); if (!$flag) { break; } $page++; } /** * If all the media are deleted from the album then delete the album at last. */ if ($flag) { $this->media->delete($id); } /* action to perform any task after deleting an album */ do_action('rtmedia_after_delete_album', $this); return $flag; }
/** * Delete * * @return type */ public function delete() { if (is_array($this->primaryKey)) { // @todo compound primary keys } $where = array($this->primaryKey => $this->originalData[$this->primaryKey]); return $this->tableGateway->delete($where); }
/** * Erase value of key * @param type $key * @return \Framework\Cache\Driver\Memcached * @throws Exception\Service */ public function erase($key) { if (!$this->_isValidService()) { throw new Exception\Service("Not connected to a valid service"); } $this->_service->delete($key); return $this; }
/** * * @param type $id */ public function destroy($id) { $produto = $this->service->show($id); if ($produto['error']) { return redirect($this->url)->with("danger", $produto['messege']); } $this->service->delete($id); return redirect($this->url)->with("success", "Produto excluido!"); }
/** * * @param type $id */ public function destroy($id) { $cliente = $this->service->show($id); if ($cliente['error']) { return redirect($this->url)->with("danger", $cliente['messege']); } $this->service->delete($id); return redirect($this->url)->with("success", "Cliente excluido!"); }
/** * * @param type $id */ public function destroy($id) { $fornecedor = $this->service->show($id); if ($fornecedor['error']) { return redirect($this->url)->with("danger", $fornecedor['messege']); } $this->service->delete($id); return redirect($this->url)->with("success", "Fornecedor excluido!"); }
/** * 删除数据 * $whereData说明:支持k、v、s的数组结构, * 例如:$whereData = array( * array('k'=>'shopId','v'=>1,'s'=>'='), * array('k'=>'orderStatus','v'=>'waitpay','s'=>'='), * array('k'=>'createdTime','v'=>'1365389457','s'=>'>='), * ) * 默认数组元素之间的关系为AND关系,牵涉到具体规则按相应规则处理,规则如下: * 1、若$whereData为以为数组,数组元素的键为属性名,则键值对之间的关系为“=”,数组元素之间的关系为AND关系. * 例如:$whereData = array('shopId'=>1,'shopName'=>'kongfz'),则where条件为 shopId=1 && shopName='kongfz' * * 2、若$whereData为二维数组,数组元素的键为属性名,值为数组,则键值对之间的关系为IN关系。 * 例如:$whereData = array('shopId'=>array(1,2,3,..)),则where条件为 shopId in (1,2,3,..) * * 3、若$whereData中的数组元素的键为OR,则值必须包括两个及以上的数组,数组之间为OR关系; * 例如:$whereData = array('shopId'=>1, * 'OR'=>array('orderStatus'=>'waitSellerConfirmed','orderStatus'=>'waitPay') * ), * 则where条件之间的关系为:shopId=1 && (orderStatus='waitSellerConfirmed' && orderStatus='waitPay') * * 4、若$whereData为一维数组,且各个键为k、v、s,则where条件之间的关系是:$whereData['k']. $whereData['s']. $whereData['v'] * 例如:$whereData = array('k'=>'shopName','v'=>'%kongfz%','s'=>'like'), * 则where条件之间的关系为:shopName like '%kongfz%' * * 5、若$whereData为二维数组,且一维数组的键k、v、s,$whereData['s'] = 'IN',$whereData['v']为一维数组, * 则其关系为$whereData['k'] IN (implode(',',$whereData['v'])), * 例如:$whereData = array('k'='shopId','v'=>array(1,2,3,..),'s'=>'IN'), * 则其关系为shopId IN (1,2,3,...) * * 6、若$whereData 为多维数组,且数组都是满足k、v、s的数组结构, * 例如:$whereData = array( * array('k'=>'shopId','v'=>1,'s'=>'='), * array('k'=>'orderStatus','v'=>'waitpay','s'=>'='), * array('k'=>'createdTime','v'=>'1365389457','s'=>'>='), * ), * 则where条件之间的关系为:shopId=1 && orderStatus='waitpay' && createdTime>='1365389457' * @param array $whereData 一维数组或k、v、s结构组成的数组。一维数组元素之间为and关系,键和值为等于关系;k、v、s结构数组,k:属性名,v:属性值,s:属性名和属性值之间的操作符 * @param string $table 删除数据的表,若为空,从默认表中删除数据 * @param boolean $isReturnAffectedRows 是否返回删除记录的条数,默认是不返回 * @return boolean */ public function delete(array $whereData, $table = '', $isReturnAffectedRows = false) { if (is_null($this->db)) { $this->db = \Util\Db\Manager::getInstance($this->dbName); } //如果方法中没传递表名,则向默认表中插入数据 $table = is_string($table) && $table != '' ? $table : $this->defaultTable; $state = $this->db->delete($table, $whereData); if ($isReturnAffectedRows && $state) { return $this->db->getAffectedRows(); } return $state; }
/** * Desactiva una página/controlador. * @param type $page */ private function disable_page($page) { if ($page->name == $this->page->name) { $this->new_error_msg("No puedes desactivar esta página (" . $page->name . ")."); } else { if (!$page->delete()) { $this->new_error_msg('Imposible eliminar la página ' . $page->name . '.'); } } }
/** * * @param type $id */ public function destroy($id) { $this->service->delete($id); }
/** * * @param type $user * @return type */ public function deleteUser($user) { return $user->delete(); }
protected function clean_checked_tables() { self::$checked_tables = array(); $this->cache->delete('fs_checked_tables'); }
/** * Remove options values from the database. */ public function uninstall() { $this->options->delete(); }
/** * Deletes a contact * @param type $artist_id * @return type */ public function deleteContact($contact_id) { $this->tableGateway->delete(array('contact_id' => $contact_id)); return; }
/** * * @param type $artist_id * @return type */ public function deleteArtist($artist_id) { $this->tableGateway->delete(array('artist_id' => $artist_id)); return; }
/** * Edit and save a specific type 'page' Content. * * @param string|null $id Cms Content id. * @return void Redirects on successful edit, renders view otherwise. * @throws \Cake\Network\Exception\NotFoundException When record not found. */ public function edit($id = null) { if ($id) { $cmsContent = $this->Content->get($id); if ($cmsContent->cms_content_type_id != $this->type_id) { $this->Flash->error(__('The Content type is not page')); return $this->redirect(['action' => 'index']); } } if ($this->request->is(['patch', 'post', 'put'])) { if (!isset($this->request->data['id'])) { $this->request->data['id'] = $id; } if (isset($this->request->data['button_publish_action'])) { $this->request->data['cms_content_status_id'] = 2; } if ($this->Content->save($this->request->data)) { if (isset($this->request->data['related']['page']) && count($this->request->data['related']['page'])) { $items = $this->request->data['related']['page']; $params = ['parent_id' => $id, 'cms_content_type_id' => 1, 'cms_content_status_id' => 1]; $this->Content->saveRelatedItems($id, $items, $params); } if (isset($this->request->data['related']['attached']) && count($this->request->data['related']['attached'])) { $items = $this->request->data['related']['attached']; $params = ['parent_id' => $id, 'cms_content_type_id' => 3, 'cms_content_status_id' => 3]; $this->Content->saveRelatedItems($id, $items, $params); } if (isset($this->request->data['related']['image']) && count($this->request->data['related']['image'])) { $items = $this->request->data['related']['image']; $params = ['parent_id' => $id, 'cms_content_type_id' => 4, 'cms_content_status_id' => 3]; $this->Content->saveRelatedItems($id, $items, $params); } if (isset($this->request->data['related']['option']) && count($this->request->data['related']['option'])) { $this->Content->saveRelatedOptions($id, $this->request->data['related']['option']); } if (isset($this->request->data['delete_ck']['content_id'])) { foreach ($this->request->data['delete_ck']['content_id'] as $key => $val) { $this->Content->delete($key); } } if (isset($this->request->data['delete_ck']['option_id'])) { foreach ($this->request->data['delete_ck']['option_id'] as $key => $val) { $this->Content->deleteRelatedOption($key); } } $this->Flash->success('The cms content has been saved.'); if (isset($this->request->data['button_save_action'])) { return $this->redirect(['action' => 'edit', $id]); } else { return $this->redirect(['action' => 'index']); } } else { $this->Flash->error('The cms content could not be saved. Please, try again.'); return $this->redirect(['action' => 'edit', $id]); } } $cmsContent['parent_page_list'] = $this->Content->getPageList($id); $cmsContent['content_status_list'] = ['1' => 'Draft', '2' => 'Published']; $cmsContent['list_of_taxonomy'] = $this->Content->getTaxonomies($this->type_id); $cmsContent['list_of_taxonomy_checked'] = $this->Content->getCheckedTaxonomies($id); $cmsContent['list_of_user'] = $this->Content->getUsers($id); $cmsContent['list_of_user_checked'] = $this->Content->getCheckedUsers($id); $cmsContent['list_of_role'] = $this->Content->getRoles($id); $cmsContent['list_of_role_checked'] = $this->Content->getCheckedRoles($id); $cmsContent['related'] = array(); $cmsContent['related']['page'] = $this->Content->getRelatedItems($id, ['cms_content_type_id' => 1]); $cmsContent['related']['attached'] = $this->Content->getRelatedItems($id, ['cms_content_type_id' => 3]); $cmsContent['related']['image'] = $this->Content->getRelatedItems($id, ['cms_content_type_id' => 4]); $cmsContent['related']['option'] = $this->Content->getRelatedOptions($id); $this->set('data', $cmsContent); $this->set('_serialize', ['data']); }