當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。