Home >Backend Development >PHP Tutorial >mysql sets the phone field to be unique. After successfully inserting a record, insert a record with the same phone number. The SQL statement will report an error instead of returning an insertion error! what to do
mysql 设置phone字段为唯一 后 插如一条记录成功 再插入一条手机号一样的记录sql语句报错 而不是返回插入错误!怎么办
<code>$User=M('User'); $result=$User->add($data); if($result){ $da['code']='1'; $da['message']="注册成功"; $da['token']=$data['token']; echo json_encode($da); }else{ $da['code']='0'; $da['message']="手机已注册"; $da['token']="null"; echo json_encode($da); }```</code>