public function addAll($rows)
 {
     $result = parent::addAll($rows);
     //删除购物车中的数据
     /*if($result!==false){
           D('ShoppingCar')->where(array('member_id'=>UID))->delete();
       }*/
     return $result;
 }
Exemplo n.º 2
0
 public function add($requestData)
 {
     //>>1.取出用户选择的商品组合
     $goods_attribute_idses = $requestData['goods_attribute_ids'];
     //保存之前先删除
     $this->where(array('goods_id' => $requestData['goods_id']))->delete();
     $rows = array();
     foreach ($goods_attribute_idses as $goods_attribute_ids) {
         $rows[] = array('goods_id' => $requestData['goods_id'], 'goods_attribute_ids' => $goods_attribute_ids, 'price' => $requestData['price'][$goods_attribute_ids], 'stock' => $requestData['stock'][$goods_attribute_ids]);
     }
     if (!empty($rows)) {
         $result = parent::addAll($rows);
         if ($result === false) {
             $this->error = '保存产品出错!';
             return false;
         }
     }
 }
Exemplo n.º 3
0
 public function testAdd()
 {
     $config = $this->getConfig();
     $time = time();
     $user_model = new Model('test.user', $config);
     $data = ['username' => 'test', 'password' => md5('123456'), 'status' => 1, 'create_time' => $time];
     $user_id = $user_model->data($data)->add();
     $data = ['username' => 'test2', 'password' => md5('000000'), 'status' => 1, 'create_time' => $time];
     $user_model->add($data, true);
     $data = [['user_id' => $user_id, 'consignee' => '张三', 'area_info' => '广东深圳', 'city_id' => '42', 'area_id' => '111', 'address' => 'xx路xx号', 'mobile' => '1380000000000', 'isdefault' => '1'], ['user_id' => $user_id, 'consignee' => '李四', 'area_info' => '广东深圳', 'city_id' => '42', 'area_id' => '111', 'address' => 'xx路xx号', 'mobile' => '13999999999', 'isdefault' => '0']];
     $address_model = new Model('user_address', $config);
     $address_id = $address_model->addAll($data, [], true);
     $data = [['user_id' => $user_id, 'sn' => '10001', 'amount' => '200', 'freight_fee' => '10', 'address_id' => $address_id - 1, 'status' => '1', 'create_time' => $time], ['user_id' => $user_id, 'sn' => '10002', 'amount' => '350.80', 'freight_fee' => '10', 'address_id' => $address_id, 'status' => '0', 'create_time' => $time]];
     $address_model = new Model('order', $config);
     $address_model->addAll($data);
     $data = ['user_id' => $user_id, 'role_id' => 1];
     $config['db_name'] = 'test';
     $config['attr_case'] = 2;
     $model = new Model('', $config);
     $model->table($config['prefix'] . 'role_user')->data($data)->add();
 }