當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Db::table方法代碼示例

本文整理匯總了PHP中Db::table方法的典型用法代碼示例。如果您正苦於以下問題:PHP Db::table方法的具體用法?PHP Db::table怎麽用?PHP Db::table使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Db的用法示例。


在下文中一共展示了Db::table方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: register

 public function register()
 {
     //係統維護檢測
     service('user')->checkSystemClose();
     if (IS_POST) {
         Validate::make([['code', 'captcha', '驗證碼輸入錯誤', 1], ['password', 'confirm:password2', '兩次密碼輸入不一致', 3]]);
         //默認用戶組
         $User = new User();
         $User['username'] = Request::post('username');
         //用戶組過期時間
         $daylimit = Db::table('user_group')->where('id', v('config.register.groupid'))->pluck('daylimit');
         $User['endtime'] = time() + $daylimit * 3600 * 24;
         //獲取密碼與加密密鑰
         $info = $User->getPasswordAndSecurity();
         $User['password'] = $info['password'];
         $User['security'] = $info['security'];
         $User['email'] = Request::post('email');
         $User['qq'] = Request::post('qq');
         $User['mobile'] = Request::post('mobile');
         $User['groupid'] = v('config.register.groupid');
         $User['status'] = v('config.register.audit');
         if (!$User->save()) {
             message($User->getError(), 'back', 'error');
         }
         message('注冊成功,請登錄係統', u('login', ['from' => $_GET['from']]));
     }
     return view();
 }
開發者ID:houdunwang,項目名稱:hdcms,代碼行數:28,代碼來源:Entry.php

示例2: remove

 /**
  * 刪除用戶
  * @return bool
  */
 public function remove()
 {
     foreach ($this->relationDeleteTable as $t) {
         Db::table($t)->where('uid', $this->uid)->delete();
     }
     return TRUE;
 }
開發者ID:houdunwang,項目名稱:hdcms,代碼行數:11,代碼來源:User.php

示例3: lists

 public function lists()
 {
     if (!isset($_SESSION['user']['user_id'])) {
         go('Home/User/login');
     }
     //分配模板文件配置
     $tplData['title'] = "購物車";
     $tplData['css'] = "cart|order";
     View::with('tplData', $tplData);
     //購物車列表信息
     $cart = $_SESSION['cart'];
     $price = 0;
     foreach ($cart as $k => $v) {
         $cart[$k]['goods'] = Db::table('goods')->where('goods_id', $v['goods_id'])->first();
         $attrs = explode('-', $v['stock_attr']);
         foreach ($attrs as $key => $value) {
             $attrs[$key] = Db::table('goods_attr')->where('goods_attr_id', $value)->first();
             $attrs[$key]['attr_name'] = Db::table('shop_attr')->where('attr_id', $attrs[$key]['attr_id'])->pluck('attr_name');
         }
         $cart[$k]['attr'] = $attrs;
         $price += $v['goods_price'] * $v['buy_num'];
         //總價
     }
     View::with('cart', $cart);
     View::with('price', $price);
     //收貨地址列表
     $address = new \Home\Model\Address();
     $addressData = $address->getAll();
     View::with('addressData', $addressData);
     // p($addressData);
     View::make($this->tpl . 'order.html');
 }
開發者ID:ChenHuaPHP,項目名稱:ZOLshop,代碼行數:32,代碼來源:OrderController.php

示例4: doSiteSitePost

 public function doSiteSitePost()
 {
     if (IS_POST) {
         $data = json_decode($_POST['data'], TRUE);
         $data['site_info'] = $_POST['data'];
         $insertId = $this->web->save($data);
         $web['id'] = $this->webid ?: $insertId;
         //添加回複規則
         $rule = [];
         $rule['rid'] = Db::table('reply_cover')->where('web_id', $web['id'])->pluck('rid');
         $rule['module'] = 'cover';
         $rule['name'] = '微站:' . $data['title'];
         $rule['keywords'] = [['content' => $data['keyword']]];
         $rid = service('WeChat')->rule($rule);
         //添加封麵回複
         $replyCover = new ReplyCover();
         $replyCover->where('rid', $rid)->delete();
         $data['web_id'] = $web['id'];
         $data['rid'] = $rid;
         $data['module'] = 'article';
         $data['url'] = '?a=entry/home&m=article&t=web&siteid=' . SITEID . '&webid=' . $web['id'];
         $replyCover->save($data);
         message('保存站點數據成功', site_url('site'), 'success');
     }
     if ($this->webid) {
         //編輯數據時
         $web = $this->web->find($this->webid);
         $field = json_decode($web['site_info'], TRUE);
         $field['id'] = $this->webid;
     }
     View::with('field', isset($field) ? json_encode($field, JSON_UNESCAPED_UNICODE) : '');
     return View::make($this->template . '/manage/sitePost.php');
 }
開發者ID:houdunwang,項目名稱:hdcms,代碼行數:33,代碼來源:manage.php

示例5: belongsToMany

 /**
  * 多對多關聯
  * @param  [string] $class       [關聯類]
  * @param  [string] $middleTabe [中間表]
  * @param  [string] $relationId  [主表字段]
  * @param  [string] $primaryKey  [關聯表字段]
  * @return [object]              
  */
 protected function belongsToMany($class, $middleTable, $middlePrimaryKey, $middleRelationId)
 {
     $pKey = $this->primaryKey;
     $middle = Db::table($middleTable)->where($middlePrimaryKey, $this->{$pKey})->lists($middleRelationId);
     $instance = new $class();
     return $instance->whereIn($instance->primaryKey, array_values($middle))->get();
 }
開發者ID:arnold1119,項目名稱:cms,代碼行數:15,代碼來源:Relation.php

示例6: post

 public function post()
 {
     if (IS_POST) {
         $data = json_decode(Request::post('keyword'), TRUE);
         $data['rank'] = $data['istop'] == 1 ? 255 : min(255, intval($data['rank']));
         $data['module'] = v('module.name');
         $data['keywords'] = $data['keyword'];
         $rid = service('WeChat')->rule($data);
         //調用模塊的執行方法
         $module = new $this->moduleClass();
         //字段驗證
         if ($msg = $module->fieldsValidate($rid)) {
             message($msg, 'back', 'error');
         }
         //使模塊保存回複內容
         $module->fieldsSubmit($rid);
         message('規則保存成功', u('post', ['rid' => $rid, 'm' => v('module.name')]));
     }
     //獲取關鍵詞回複
     if ($rid = Request::get('rid')) {
         $data = Db::table('rule')->find($rid);
         if (empty($data)) {
             message('回複規則不存在', 'back', 'error');
         }
         $data['keyword'] = Db::table('rule_keyword')->orderBy('id', 'asc')->where('rid', $rid)->get();
         View::with('rule', $data);
     }
     $module = new $this->moduleClass();
     $moduleForm = $module->fieldsDisplay($rid);
     return view()->with('moduleForm', $moduleForm);
 }
開發者ID:houdunwang,項目名稱:hdcms,代碼行數:31,代碼來源:Reply.php

示例7: doWebLists

 public function doWebLists()
 {
     $Model = new CreditsRecord();
     //會員信息
     $user = Db::table('member')->where('uid', Session::get('member.uid'))->first();
     if ($timerange = q('get.timerange')) {
         //有篩選時間的
         $timerange = explode('至', $timerange);
         $total = $Model->where('uid', Session::get('member.uid'))->where('credittype', q('get.type'))->where('createtime', '>=', strtotime($timerange[0]))->where('createtime', '<=', strtotime($timerange[1]))->count();
         $page = Page::row(8)->make($total);
         $data = $Model->where('uid', Session::get('member.uid'))->where('credittype', q('get.type'))->where('createtime', '>=', strtotime($timerange[0]))->where('createtime', '<=', strtotime($timerange[1]))->limit(Page::limit())->get();
     } else {
         $total = $Model->where('uid', Session::get('member.uid'))->where('credittype', q('get.type'))->count();
         $page = Page::row(8)->make($total);
         $data = $Model->where('uid', Session::get('member.uid'))->where('credittype', q('get.type'))->limit(Page::limit())->get();
     }
     //收入
     $income = $Model->where('num', '>', 0)->where('uid', Session::get('member.uid'))->where('credittype', q('get.type'))->sum('num');
     //支出
     $expend = $Model->where('num', '<', 0)->where('uid', Session::get('member.uid'))->where('credittype', q('get.type'))->sum('num');
     View::with(['income' => $income, 'expend' => $expend]);
     View::with('page', $page);
     View::with('user', $user);
     View::with('data', $data);
     View::make($this->ucenter_template . '/credit_lists.html');
 }
開發者ID:houdunwang,項目名稱:hdcms,代碼行數:26,代碼來源:credit.php

示例8: add

 public function add()
 {
     foreach ($_POST['stock_attr'] as $k => $v) {
         if ($s = $this->db->where('stock_attr', $_POST['stock_attr'][$k])->first()) {
             //以前設置了庫存信息,更新庫存
             $data['stock_attr'] = $_POST['stock_attr'][$k];
             $data['stock_goods_sn'] = $_POST['stock_goods_sn'][$k];
             $data['stock_count'] = $_POST['stock_count'][$k];
             $data['goods_id'] = $_POST['goods_id'];
             $data['stock_id'] = $s['stock_id'];
             $this->db->save($data);
         } else {
             if ($_POST['stock_count'][$k]) {
                 //沒有設置過庫存信息,新增庫存信息,排除庫存為0的組合
                 $data['stock_attr'] = $_POST['stock_attr'][$k];
                 $data['stock_goods_sn'] = $_POST['stock_goods_sn'][$k];
                 if (!$data['stock_goods_sn']) {
                     $data['stock_goods_sn'] = 'gd' . time() . rand(100, 999);
                 }
                 $data['stock_count'] = $_POST['stock_count'][$k];
                 $data['goods_id'] = $_POST['goods_id'];
                 unset($data['stock_id']);
                 //卸載上溢出的stock_id值
                 Db::table('goods_stock')->insert($data);
             }
         }
     }
     $this->success('庫存信息更新成功', 'Goods/index');
 }
開發者ID:ChenHuaPHP,項目名稱:ZOLshop,代碼行數:29,代碼來源:GoodsStockController.php

示例9: weixin

 /**
  * 支付
  *
  * @param $param
  */
 public function weixin($param)
 {
     if (!v('module.name') || !Session::get('member.uid') || empty($param['goods_name']) || empty($param['fee']) || empty($param['body']) || empty($param['tid'])) {
         message('支付參數錯誤,請重新提交', 'back', 'error');
     }
     if ($pay = Db::table('pay')->where('tid', $param['tid'])->first()) {
         if ($pay['status'] == 1) {
             message('定單已經支付完成', $param['back_url'], 'success');
         }
     }
     $data['siteid'] = SITEID;
     $data['uid'] = Session::get('member.uid');
     $data['tid'] = $param['tid'];
     $data['fee'] = $param['fee'];
     $data['goods_name'] = $param['goods_name'];
     $data['attach'] = isset($param['attach']) ? $param['attach'] : '';
     //附加數據
     $data['module'] = v('module.name');
     $data['body'] = $param['body'];
     $data['attach'] = $param['attach'];
     $data['status'] = 0;
     $data['is_usecard'] = isset($param['is_usecard']) ? $param['is_usecard'] : 0;
     $data['card_type'] = isset($param['card_type']) ? $param['card_type'] : '';
     $data['card_id'] = isset($param['is_usecard']) ? $param['card_id'] : 0;
     $data['card_fee'] = isset($param['card_fee']) ? $param['card_fee'] : 0;
     if (empty($pay)) {
         Db::table('pay')->insertGetId($data);
     }
     Session::set('pay', ['tid' => $data['tid'], 'module' => v('module.name'), 'siteid=' => SITEID]);
     View::with('data', $data);
     View::make('server/build/template/pay.html');
 }
開發者ID:houdunwang,項目名稱:hdcms,代碼行數:37,代碼來源:Pay.php

示例10: doWebBalance

 public function doWebBalance()
 {
     if (IS_POST) {
         //檢測是否有相同金額的充值記錄,如果有就使用它,避免重複金額定單產生
         $pay = Db::table('balance')->where('fee', $_POST['fee'])->where('siteid', SITEID)->where('status', 0)->where('uid', Session::get('member.uid'))->pluck('tid');
         $data['tid'] = $pay ? $pay : Cart::getOrderId();
         $data['goods_name'] = '會員充值';
         $data['fee'] = $_POST['fee'];
         $data['body'] = '會員餘額充值';
         $data['attach'] = '';
         //附加數據
         //在會員充值表中記錄定單
         if (empty($pay)) {
             $balance['siteid'] = SITEID;
             $balance['uid'] = Session::get('member.uid');
             $balance['fee'] = $data['fee'];
             $balance['stauts'] = 0;
             $balance['createtime'] = time();
             $balance['tid'] = $data['tid'];
             Db::table('balance')->insert($balance);
         }
         Util::instance('pay')->weixin($data);
     }
     View::make($this->ucenter_template . '/balance.html');
 }
開發者ID:houdunwang,項目名稱:hdcms,代碼行數:25,代碼來源:account.php

示例11: index

 /**
  * Init the index view with the current
  * average rate data stored in the db.
  *
  * @return Response
  */
 public function index()
 {
     // Select the rates of the year 2015.
     // NOTE: Just for the purpose of the exercise,
     // would be nicer to provide all the results available
     // grouped accordingly
     $rates = Db::table('monthly_rates')->select('currency_from', 'currency_to', 'month', 'avg_rate')->where('year', 2015)->orderBy('currency_from')->orderBy('currency_to')->get();
     // Initialize the messages array as charts.js expects it
     if (empty($rates)) {
         $messages = [[]];
     } else {
         $messages = [];
     }
     $monthRates = [];
     $totRates = count($rates);
     // Aggregate the messages as an array
     // currencyfrom_currencyto => [1 => avg_rate, 2 => ...]
     // where the inner array index corresponds to a month
     for ($i = 0; $i < $totRates; $i++) {
         $rate = $rates[$i];
         $monthRates[$rate->month] = $rate->avg_rate;
         if ($i == $totRates - 1) {
             $key = $rate->currency_from . '-' . $rate->currency_to;
             $messages[$key] = $monthRates;
         } elseif ($rate->currency_from != $rates[$i + 1]->currency_from || $rate->currency_to != $rates[$i + 1]->currency_to) {
             // Build the array key and store the data
             $key = $rate->currency_from . '-' . $rate->currency_to;
             $messages[$key] = $monthRates;
             $monthRates = [];
         }
     }
     return view('socket', compact('messages'));
 }
開發者ID:staribelli,項目名稱:market-trade-processor,代碼行數:39,代碼來源:CurrencymessageController.php

示例12: belongsToMany

 /**
  * 多對多關聯
  *
  * @param  [string] $class       [關聯類]
  * @param  [string] $middleTabe [中間表]
  * @param  [string] $localKey  [主表字段]
  * @param  [string] $foreignKey  [關聯表字段]
  *
  * @return [object]
  */
 protected function belongsToMany($class, $middleTable, $localKey = NULL, $foreignKey = NULL)
 {
     $instance = new $class();
     $localKey = $localKey ?: $this->table . '_' . $this->pk;
     $foreignKey = $foreignKey ?: $instance->getTableName() . '_' . $instance->getPrimaryKey();
     $middle = Db::table($middleTable)->where($localKey, $this[$this->pk])->lists($foreignKey);
     return $instance->whereIn($instance->getPrimaryKey(), array_values($middle))->get();
 }
開發者ID:houdunwang,項目名稱:hdphp,代碼行數:18,代碼來源:Relation.php

示例13: getAttrName

 public function getAttrName($goods_id)
 {
     //獲取商品類型
     $type_id = Db::table('goods')->where('goods_id', $goods_id)->pluck('type_id');
     //獲取商品規格
     $attr_name = DB::table('shop_attr')->where('shop_type_id', $type_id)->where('attr_type', 2)->lists('attr_name');
     return $attr_name;
 }
開發者ID:ChenHuaPHP,項目名稱:ZOLshop,代碼行數:8,代碼來源:GoodsAttr.php

示例14: del

 /**
  * 刪除文章
  *
  * @param $aid 文章編號
  *
  * @return bool
  */
 public function del($aid)
 {
     $rid = Db::table('reply_cover')->where('module', 'article:aid:' . $aid)->pluck('rid');
     service('WeChat')->removeRule($rid);
     Db::table('web_article')->where('aid', $aid)->delete();
     Db::table('reply_cover')->where('module', 'article:aid:' . $aid)->delete();
     return TRUE;
 }
開發者ID:houdunwang,項目名稱:hdcms,代碼行數:15,代碼來源:WebArticle.php

示例15: getIdChannelById

 public function getIdChannelById($id)
 {
     $id_channel = Db::table('rss_item_for_channel')->select('id_channel')->where('id', '=', $id)->get();
     if (empty($id_channel)) {
         throw new \Exception('Can not find channel for this item.');
     }
     return $id_channel[0]->id_channel;
 }
開發者ID:bkowalczyk88,項目名稱:feedRss,代碼行數:8,代碼來源:RssItemsList.php


注:本文中的Db::table方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。