当前位置: 首页>>代码示例>>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;未经允许,请勿转载。