public function delete($data) { $db = new DB(); for ($i = 0; $i < count($data); $i++) { $db->delete($data[$i], 'style'); } }
/** * Menghapus record tertentu berdasarkan column id. * * @return bool */ public function delete($id) { try { $this->db->delete($this->table, ['id', '=', $id]); return true; } catch (Exception $e) { throw new Exception("Cannot delete record."); } }
public function delete_by_uid($uid) { $user = parent::fetch($uid); if (self::checkfounder($user)) { //创始人不能删除 return false; } if (parent::delete($uid)) { C::t('user_field')->delete($uid); C::t('user_profile1')->delete($uid); C::t('user_status')->delete($uid); C::t('organization_user')->delete_by_uid($uid, 0); DB::delete('user_thame', "uid='{$uid}'"); //删除用户主题 DB::delete('user_playlist', "uid='{$uid}'"); //删除播放列表 //删除用户文件 foreach (DB::fetch_all("select fid from %t where uid=%d and gid<1 ", array('folder', $uid)) as $value) { C::t('folder')->delete_by_fid($value['fid'], true); } //删除用户云链接 foreach (DB::fetch_all("select * from %t where 1", array('connect')) as $cloud) { if ($cloud['dname']) { C::t($cloud['dname'])->delete_by_uid($uid); } } wx_deleteUser($uid); return true; } return false; }
public function before() { if (!User::current()) { $this->redirect('/login'); } $url = str_replace('.', '_', URL::base() . $this->request->uri()); if (isset($_GET[$url])) { unset($_GET[$url]); } if (isset($_GET[$url . '/'])) { unset($_GET[$url . '/']); } if (Group::current('is_admin') || Group::current('show_all_jobs') && Group::current('allow_finance')) { Pager::$counts[] = 2500; } if (Arr::get($_GET, 'limit') && in_array($_GET['limit'], Pager::$counts)) { DB::update('users')->set(array('list_items' => intval($_GET['limit'])))->where('id', '=', User::current('id'))->execute(); die(json_encode(array('success' => 'true'))); } if (Arr::get($_GET, 'dismiss')) { DB::delete('notifications')->where('user_id', '=', User::current('id'))->and_where('id', '=', intval($_GET['dismiss']))->execute(); die(json_encode(array('success' => 'true'))); } if (!Group::current('allow_assign')) { Enums::$statuses[Enums::STATUS_UNALLOC] = 'Not active'; } View::set_global('notifications', DB::select()->from('notifications')->where('user_id', '=', User::current('id'))->order_by('id', 'desc')->execute()); }
/** * update account fields * * @param integer $account_id * @param array $data_fields * @return boolean */ public function updateAccountFields($account_id = '', array $data_fields = array()) { if (!is_numeric($account_id)) { return false; } // delete not exists fields. $current_af = static::getData($account_id); if ($current_af->count() > 0) { foreach ($current_af as $af) { if (!isset($data_fields[$af->field_name])) { \DB::delete(static::$_table_name)->where('account_id', $account_id)->where('field_name', $af->field_name)->execute(); } } } unset($af, $current_af); // update or insert fields. if (is_array($data_fields) && !empty($data_fields)) { foreach ($data_fields as $field_name => $field_value) { $result = \DB::select()->from(static::$_table_name)->where('account_id', $account_id)->where('field_name', $field_name)->execute(); if (count($result) <= 0) { // use insert \DB::insert(static::$_table_name)->set(['account_id' => $account_id, 'field_name' => $field_name, 'field_value' => $field_value])->execute(); } else { // use update \DB::update(static::$_table_name)->value('field_value', $field_value)->where('account_id', '=', $account_id)->where('field_name', $field_name)->execute(); } unset($result); } unset($field_name, $field_value); } return true; }
public function delete_by_appid($appid) { if (!$appid) { return false; } return DB::delete($this->_table, " appid='{$appid}'"); }
public function delete_by_identifier($identifier) { if (!$identifier) { return; } DB::delete('common_plugin', DB::field('identifier', $identifier)); }
static function delete_images($id) { $row = DB::select('item_image', 'id=' . $id); if ($row) { if ($row['root_id']) { //Ảnh gốc DB::delete('item_image', 'root_id=' . $row['root_id']); } else { DB::delete('item_image', 'id=' . $id); } //update memcache IMG $sql = "SELECT item_id FROM item_image WHERE (id = {$id} OR root_id = {$id}) " . (User::have_permit(ADMIN_IMAGE) ? '' : " AND user_id=" . User::id()); $re = DB::query($sql); if ($re) { $item = mysql_fetch_assoc($re); if ($item["item_id"]) { require_once ROOT_PATH . 'core/Item.php'; Item::get_item_images($item["item_id"], 1); } } //update memcache IMG if ($row['img_url']) { if (DB::query("UPDATE item SET img_url='' WHERE img_url='" . $row['img_url'] . "'") && MEMCACHE_ON) { $sql = "SELECT * FROM item WHERE img_url = '{$row['img_url']}'"; $re = DB::query($sql); while ($item_memcache = mysql_fetch_assoc($re)) { $item_memcache['img_server'] = 0; $item_memcache['img_url'] = ''; AZMemcache::do_put("item:" . $item_memcache['id'], $item_memcache); } } AZLib::ftp_image_delete_file($row['img_url'], $row['img_server']); } } }
public function delete_by_dateline($dateline) { if (!is_numeric($dateline)) { return false; } return DB::delete($this->_table, DB::field('dateline', $dateline, '<=')); }
/** * update account levels * * @param integer $account_id * @param array $data_level * @return boolean */ public function updateLevels($account_id = '', $data_level = array()) { // delete not exists level $lvls = static::query()->where('account_id', $account_id); if ($lvls->count() > 0) { foreach ($lvls->get() as $lvl) { if (!in_array($lvl->level_group_id, $data_level)) { \DB::delete(static::$_table_name)->where('account_id', $account_id)->where('level_id', $lvl->level_id)->execute(); } } } unset($lvls, $lvl); // update or insert fields if (is_array($data_level) && !empty($data_level)) { foreach ($data_level as $level_group_id) { $result = \DB::select()->from(static::$_table_name)->where('account_id', $account_id)->where('level_group_id', $level_group_id)->execute(); if (count($result) <= 0) { // not exists, use insert. \DB::insert(static::$_table_name)->set(['account_id' => $account_id, 'level_group_id' => $level_group_id])->execute(); } unset($result); } } // clear cache \Extension\Cache::deleteCache('model.accountLevelPermission-checkLevelPermission-' . \Model_Sites::getSiteId(false)); return true; }
/** Удаление записи */ public function delete($id) { if ($id) { return (bool) DB::delete(self::$table_articles)->where('id', '=', $id)->execute(); } return false; }
public function delete_by_taskid($taskid) { if (!$taskid) { return; } return DB::delete($this->_table, DB::field('taskid', $taskid)); }
/** * Deletes a single record while ignoring relationships. * * @chainable * @throws Kohana_Exception * @return ORM */ public function delete() { if (!$this->_loaded) { throw new Kohana_Exception('Cannot delete :model model because it is not loaded.', array(':model' => $this->_object_name)); } //remove image $this->delete_image(); //remove ads, will remove reviews, images etc... $ads = new Model_Ad(); $ads = $ads->where('id_user', '=', $this->id_user)->find_all(); foreach ($ads as $ad) { $ad->delete(); } //bye profile pic $this->delete_image(); //delete favorites DB::delete('favorites')->where('id_user', '=', $this->id_user)->execute(); //delete reviews DB::delete('reviews')->where('id_user', '=', $this->id_user)->execute(); //delete orders DB::delete('orders')->where('id_user', '=', $this->id_user)->execute(); //remove visits ads DB::update('visits')->set(array('id_user' => NULL))->where('id_user', '=', $this->id_user)->execute(); //delete subscribtions DB::delete('subscribers')->where('id_user', '=', $this->id_user)->execute(); //delete posts DB::delete('posts')->where('id_user', '=', $this->id_user)->execute(); //delete messages DB::delete('messages')->where('id_user_from', '=', $this->id_user)->or_where('id_user_to', '=', $this->id_user)->execute(); parent::delete(); }
function usesubmit() { global $_G; if (empty($_G['gp_pid'])) { showmessage(lang('magic/repent', 'repent_info_nonexistence')); } $_G['tid'] = $_G['gp_ptid']; $post = getpostinfo($_G['gp_pid'], 'pid', array('p.first', 'p.tid', 'p.fid', 'p.authorid', 'p.replycredit', 't.status as thread_status')); $this->_check($post); require_once libfile('function/post'); require_once libfile('function/delete'); if ($post['first']) { if ($have_replycredit = DB::fetch_first("SELECT * FROM " . DB::table('forum_replycredit') . " WHERE tid ='{$post['tid']}' LIMIT 1")) { if ($replycredit = DB::result_first("SELECT replycredit FROM " . DB::table('forum_thread') . " WHERE tid = '{$post['tid']}'")) { updatemembercount($post['authorid'], array($_G['setting']['creditstransextra'][10] => $replycredit)); } DB::delete('forum_replycredit', "tid = '{$post['tid']}'"); DB::delete('common_credit_log', "operation IN ('RCT', 'RCA', 'RCB') AND relatedid IN({$post['tid']})"); } deletethread(array($post['tid'])); updateforumcount($post['fid']); } else { if ($post['replycredit'] > 0) { updatemembercount($post['authorid'], array($_G['setting']['creditstransextra'][10] => -$post['replycredit'])); DB::delete('common_credit_log', "uid = '{$post['authorid']}' AND operation = 'RCA' AND relatedid IN({$post['tid']})"); } deletepost(array($_G['gp_pid'])); updatethreadcount($post['tid']); } usemagic($this->magic['magicid'], $this->magic['num']); updatemagiclog($this->magic['magicid'], '2', '1', '0', 0, 'tid', $_G['tid']); showmessage(lang('magic/repent', 'repent_succeed'), $post['first'] ? 'forum.php?mod=forumdisplay&fid=' . $post['fid'] : dreferer(), array(), array('showdialog' => 1, 'locationtime' => true)); }
public function delete_by_styleid($id, $stylevarids = array()) { if (!$id) { return; } DB::delete($this->_table, ($stylevarids ? DB::field('stylevarid', $stylevarids) . ' AND ' : '') . DB::field('styleid', $id)); }
/** * Setting the display of pages * * @uses Arr::merge * @uses Config::load * @uses Message::success */ public function action_settings() { $this->title = __('Page Settings'); $post = Config::load('page'); $action = Route::get('admin/page')->uri(array('action' => 'settings')); $vocabs = array(__('none')); $view = View::factory('admin/page/settings')->set('vocabs', $vocabs)->set('post', $post)->set('action', $action); $vocabs = Arr::merge($vocabs, ORM::factory('term')->where('lft', '=', 1)->where('type', '=', 'page')->find_all()->as_array('id', 'name')); if ($this->valid_post('page_settings')) { unset($_POST['page_settings'], $_POST['_token'], $_POST['_action']); $cats = $post->get('category', array()); foreach ($_POST as $key => $value) { if ($key == 'category') { $terms = array_diff($cats, $value); if ($terms) { DB::delete('posts_terms')->where('parent_id', 'IN', array_values($terms))->execute(); } } $post->set($key, $value); } Log::info('Page Settings updated.'); Message::success(__('Page Settings updated!')); $this->request->redirect(Route::get('admin/page')->uri(array('action' => 'settings')), 200); } $this->response->body($view); }
public static function getManyToManyUpdate($arguments) { $through_table = $own_id = $foreign_id = $post_name = []; if (is_array($arguments)) { foreach ($arguments as $arg) { $through_table[] = $arg[0]; $own_id[] = $arg[1]; $foreign_id[] = $arg[2]; $post_name[] = $arg[3]; } } elseif (func_num_args() == 4) { $through_table = [func_get_arg(0)]; $own_id = [func_get_arg(1)]; $foreign_id = [func_get_arg(2)]; $post_name = [func_get_arg(3)]; } return function ($table, $post, $primaryColumn, $primary) use($through_table, $own_id, $foreign_id, $post_name) { /** * Many-to-many update first */ foreach ($through_table as $index => $ttable) { DB::delete($ttable)->where($own_id[$index], '=', $primary)->execute(); if (!empty($post[$post_name[$index]]) && $primary != 0) { foreach ($post[$post_name[$index]] as $id) { DB::insert($ttable)->values([$own_id[$index] => $primary, $foreign_id[$index] => $id])->execute(); } unset($post[$post_name[$index]]); } } /** * Regular update */ DB::update($table)->set($post)->where($primaryColumn, '=', $primary)->execute(); }; }
public function action_delete() { $id = $this->request->query("id"); DB::delete("service")->where("id", "=", $id)->execute(); $out = $this->listServices(); $this->template->content = json_encode($out); }
public function delete_by_tid($tids) { if (!$fids) { return; } return DB::delete($this->_table, DB::field('tid', $tids)); }
public function delete_by_type($type) { if (!$type) { return; } return DB::delete($this->_table, DB::field('type', $type)); }
public function action_delete() { $id = $this->request->param('id'); DB::delete('address')->where('id', '=', $id)->execute(); Messages::save('Address was successfully deleted!', 'info'); $this->redirect('/address'); }
public function delete_by_uid($uid) { if (!$uid) { return null; } return DB::delete($this->_table, DB::field('uid', $uid)); }
public function delete_group($id) { $group = $this->get($id); $db = new DB(); $selector = array('id', '$id'); $db->delete($selector, ''); }
public function delete_by_id_idtype($ids, $idtype) { if (empty($ids) || empty($idtype)) { return false; } DB::delete($this->_table, DB::field($idtype, $ids)); }
function delete($value, $key = "id") { global $_G; if (!$value) { return array('status' => 'error', 'msg' => '要删除的图片值不能为空'); } $value = addslashes($value); $key = addslashes($key); $rs = DB::fetch_first("SELECT * FROM " . DB::table('images') . " WHERE {$key} = '{$value}'"); if (!$rs['id']) { return array('status' => 'error', 'msg' => '图片不存在,或不是通过后台上传的,如果图片连接失效,您可手动清空图片内容', 'a' => 'readonly'); } if ($rs['location'] == 1) { if ($_G[adminid] != 1 && $_G[uid] != $rs[uid]) { return array('status' => 'error', 'msg' => '您无法删除非自己上传的图片', 'a' => 'readonly'); } DB::delete('images', "id=" . $rs[id]); @unlink(ROOT_PATH . $rs[img_url]); return array('status' => 'success', 'msg' => '删除成功,请提交表单保存', 'a' => 'del'); } $response = $imgService->deleteUZImgById($rs['img_id']); if ($response->isSuccess()) { DB::delete('images', "id=" . $rs[id]); return array('status' => 'success', 'msg' => '删除成功,请提交表单保存', 'a' => 'del'); } else { return array('status' => 'error', 'msg' => '图片删除失败' . $response->getErrorMsg()); } }
public function delete_by_ctid($ctid) { if (!$ctid) { return false; } return DB::delete($this->_table, DB::field('ctid', $ctid)); }
public function delete($pid, $mid) { //получаем значение $value = DB::select()->from('group_param_values')->where('mid', '=', $mid)->and_where('pid', '=', $pid)->execute()->current(); $result = DB::delete('group_param_values')->where('id', '=', $value['id'])->execute(); $result = DB::delete('chars')->where('id', '=', $value['value'])->execute(); }
function FilterForm() { Form::Form('FilterForm'); CGlobal::$website_title = 'Thuộc tính chuyên mục'; $fgroup_id = (int) Url::get('fgroup_id', 0); if ($fgroup_id) { $this->filter_group = DB::select('filter_group', 'id=' . $fgroup_id); } if (!$this->filter_group) { Url::redirect_current(); } ############################################################################# #Remove filter_group khỏi danh mục $catid_remove = (int) Url::get('catid_remove', 0); if ($catid_remove) { Category::remove_cat_group_filer($catid_remove, $fgroup_id); Url::redirect_current(array('cmd', 'fgroup_id')); } #Remove filter_group khỏi danh mục ############################################################################# ############################################################################# #Xóa filter $f_del = (int) Url::get('f_del', 0); if ($f_del) { $this->filter = DB::select('filter', 'id=' . $f_del); if ($this->filter && $this->filter['fgid'] == $this->filter_group['id']) { DB::delete("filter", "id={$f_del}"); } AZLib::getFilters(1); Url::redirect_current(array('cmd', 'fgroup_id')); } #Xóa filter ############################################################################# }
public function delete_by_variable($pluginid, $variable) { if (!$pluginid || !$variable) { return; } DB::delete($this->_table, DB::field('pluginid', $pluginid) . ' AND ' . DB::field('variable', $variable)); }
/** * Deletes a single record while ignoring relationships. * * @chainable * @throws Kohana_Exception * @return ORM */ public function delete() { if (!$this->_loaded) { throw new Kohana_Exception('Cannot delete :model model because it is not loaded.', array(':model' => $this->_object_name)); } //remove image $this->delete_image(); //remove ads, will remove reviews, images etc... $ads = new Model_Ad(); $ads = $ads->where('id_user', '=', $this->id_user)->find_all(); foreach ($ads as $ad) { $ad->delete(); } //bye profile pic $this->delete_image(); //delete favorites DB::delete('favorites')->where('id_user', '=', $this->id_user)->execute(); //delete reviews DB::delete('reviews')->where('id_user', '=', $this->id_user)->execute(); //delete orders DB::delete('orders')->where('id_user', '=', $this->id_user)->execute(); //delete subscribtions DB::delete('subscribers')->where('id_user', '=', $this->id_user)->execute(); //delete posts DB::delete('posts')->where('id_user', '=', $this->id_user)->execute(); //delete messages DB::delete('messages')->where('id_user_from', '=', $this->id_user)->or_where('id_user_to', '=', $this->id_user)->execute(); //unsusbcribe from elasticemail if (Core::config('email.elastic_listname') != '') { ElasticEmail::unsubscribe(Core::config('email.elastic_listname'), $this->email); } parent::delete(); }