当前位置: 首页>>代码示例>>PHP>>正文


PHP CommonModel::addData方法代码示例

本文整理汇总了PHP中Common\Model\CommonModel::addData方法的典型用法代码示例。如果您正苦于以下问题:PHP CommonModel::addData方法的具体用法?PHP CommonModel::addData怎么用?PHP CommonModel::addData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Common\Model\CommonModel的用法示例。


在下文中一共展示了CommonModel::addData方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: addData

 /**
  * 添加数据
  * @return mixed
  */
 public function addData()
 {
     $data['user_id'] = session('user.id');
     $data['name'] = I('name');
     $data['phone'] = I('phone');
     $data['address'] = I('address');
     return parent::addData($data);
 }
开发者ID:foryoufeng,项目名称:thinkmobile,代码行数:12,代码来源:ClanModel.class.php

示例2: addData

 public function addData()
 {
     $brand_id = I('get.brand_id');
     $user_id = $this->user_id;
     if (!$user_id) {
         return $this->nologin;
     } else {
         $where['brand_id'] = $brand_id;
         $where['user_id'] = $user_id;
         $res = $this->where($where)->find();
         if ($res) {
             return $this->hbrand;
         }
         if ($brand_id == '') {
             return $this->nobrand;
         }
         $time = time();
         $data['user_id'] = $this->user_id;
         $data['brand_id'] = $brand_id;
         $data['time'] = $time;
         $list = parent::addData($data);
         if ($list == CommonModel::MSUCCESS) {
             return $this->success;
         } else {
             return $this->fail;
         }
     }
     //return $list;
 }
开发者ID:foryoufeng,项目名称:thinkmobile,代码行数:29,代码来源:FocusModel.class.php

示例3: addData

 public function addData()
 {
     $user_id = session('user.user_id');
     if (!$user_id) {
         return $this->nologin;
     } else {
         $goods_id = I('get.goods_id');
         //蹇呬紶鍙傛暟锛岃幏寰楁敹钘忕殑閭d釜鍟嗗搧
         if ($goods_id == '') {
             return $this->nogoods;
         }
         $where['goods_id'] = $goods_id;
         $where['user_id'] = $user_id;
         $res = $this->where($where)->find();
         if ($res) {
             return $this->hgoods;
         }
         $data['goods_id'] = $goods_id;
         $data['user_id'] = $user_id;
         $data['add_time'] = time();
         $list = parent::addData($data);
         if ($list == CommonModel::MSUCCESS) {
             return $this->success;
         } else {
             return $this->fail;
         }
     }
 }
开发者ID:foryoufeng,项目名称:thinkmobile,代码行数:28,代码来源:CollectModel.class.php

示例4: addCart

 private function addCart($goods_id, $attr_id, $number)
 {
     $data = $this->getAttr($goods_id);
     //获取商品属性
     if ($data && !$attr_id) {
         //有商品属性没有传商品属性id
         return $this->noattrid;
         //没有商品
     }
     $result = $this->getCart($goods_id, $attr_id);
     $amount = $this->getNumber($goods_id, $attr_id);
     //获取库存
     if ($result) {
         //购物车中存在商品就更新
         if (intval($number) + intval($result['goods_number']) > $amount) {
             return $this->nonum;
             //库存不足
         }
         $res = $this->addNum($goods_id, $attr_id, $number);
         if ($res) {
             return $this->success;
             //添加成功
         } else {
             return $this->fail;
             //添加失败
         }
     } else {
         //没有就加入购物车
         $amount = $this->getNumber($goods_id, $attr_id);
         if (intval($number) > $amount) {
             return $this->nonum;
             //库存不足
         }
         $info = array('user_id' => $this->user_id, 'session_id' => session_id(), 'goods_id' => $goods_id, 'goods_attr_id' => $attr_id, 'goods_number' => $number, 'goods_price' => $this->getPrice($goods_id, $attr_id));
         $where['goods_id'] = $goods_id;
         $ginfo = $this->goods->field('goods_sn,market_price,shop_price,goods_name')->where($where)->find();
         //获取商品信息
         $product = $this->getProduct($goods_id, $attr_id);
         $datas = array_merge($info, $ginfo, $product);
         $datas['goods_attr'] = $this->getAttrName($goods_id, $attr_id);
         $res = parent::addData($datas);
         if ($res == CommonModel::MSUCCESS) {
             return $this->success;
             //添加成功
         } else {
             return $this->fail;
             //添加失败
         }
     }
 }
开发者ID:foryoufeng,项目名称:thinkmobile,代码行数:50,代码来源:CartModel.class.php


注:本文中的Common\Model\CommonModel::addData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。