Home  >  Q&A  >  body text

Problem with adding database records using THINKPHP3?

if ($cart_info) {

$data['num'] = intval($cart_info['num']) intval($num);

//Judge inventory

if (intval($check_info['num'])<=$data['num']) {

echo json_encode(array('status'=>0,'err '=>'Out of stock!'));

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']='Add'

$res=$shpp->add($data);

}


## if($res){

echo json_encode (array('status'=>1,'cart_id'=>$res)); //This product has been successfully added to your shopping cart

exit;

}else{

echo json_encode(array('status'=>0,'err'=>'Join failed.'));

exit;

}




##$res=$shpp->add($data); Return after adding the record ID=1

But my database ID value is 5,

The ID of the database is not synchronized with the newly added records.

冥冥中有主宰冥冥中有主宰2147 days ago1189

reply all(0)I'll reply

No reply
  • Cancelreply