if ($cart_info) {
$data['num'] = intval($cart_info['num'])+intval($num);
//判断库存
if (intval($check_info['num'])<=$data['num']) {
echo json_encode(array('status'=>0,'err'=>'库存不足!'));
exit;
}
$res = $shpp->where('id='.intval($cart_info['id']))->save($data);
}else{
$data['pid']=intval($pid);
$data['num']=intval($num);
$data['addtime']=time();
$data['uid']=intval($uid);
$data['shop_id']=intval($check_info['shop_id']);
$ptype = 1;
if (intval($check_info['pro_type'])) {
$ptype = intval($check_info['pro_type']);
}
$data['type']=$ptype;
$data['price'] = $check_info['price_yh'];
$data['aa']='增加'
$res=$shpp->add($data);
}
if($res){
echo json_encode(array('status'=>1,'cart_id'=>$res)); //该商品已成功加入您的购物车
exit;
}else{
echo json_encode(array('status'=>0,'err'=>'加入失败.'));
exit;
}
$res=$shpp->add($data);增加记录后后返回ID=1
但我的数据库ID值却为5,
数据库的ID 没有与新增的记录同步。