马春杰杰博客
致力于深度学习经验分享!

[WP]MySQL提示:#1062 - Duplicate entry '0' for key 'PRIMARY'

使用WordPress中MySQL插入数据:

$wpdb->insert($table,array('murl' => $tag->name , 'status' => '9')) ;

结果提示:#1062 - Duplicate entry '0' for key 'PRIMARY',然后插入数据不成功,提示如下:

这是因为之前我们指定了主键,但是主键不允许重复,所以我们每次在插入值的时候都要插入对应的主键,因此只需要把主键加上就可以插入了:

$wpdb->insert($table,array('zizeng' => $i,'murl' => $tag->name , 'status' => '9')) ;

赞(383) 打赏
版权声明:本文采用知识共享 署名4.0国际许可协议 [BY-NC-SA] 进行授权
文章名称:《[WP]MySQL提示:#1062 - Duplicate entry '0' for key 'PRIMARY'》
文章链接:https://www.machunjie.com/web/webjiaocheng/566.html
本站资源仅供个人学习交流,请于下载后24小时内删除,不允许用于商业用途,否则法律问题自行承担。

评论 抢沙发

觉得文章有用就打赏一下文章作者

非常感谢你的打赏,我们将继续提供更多优质内容,让我们一起创建更加美好的网络世界!

支付宝扫一扫

微信扫一扫

:smile: :sad: :arrow: :cool: :confused: :cry: :eek: :evil: :exclaim: :idea: :lol: :mad: :mrgreen: :neutral: :question: :razz: :redface: :rolleyes: :surprised: :wink: :biggrin: :twisted: