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

WBOY
Release: 2016-09-26 08:27:17
Original
1108 people have browsed it

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>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template