程序员最近都爱上了这个网站  程序员们快来瞅瞅吧!  it98k网:it98k.com

本站消息

站长简介/公众号

  出租广告位,需要合作请联系站长

+关注
已关注

分类  

暂无分类

标签  

暂无标签

日期归档  

暂无数据

Weird Duplicate Entry Error on Primary Key

发布于2023-05-25 21:36     阅读(571)     评论(0)     点赞(3)     收藏(5)


I have a live project more than 5 years. And today i had a weird mistake. I wanted to update some of my products. And there exists a duplicate entry error.

enter image description here

I have no field as product_id in my products table. 12479 is id of my product. id is primary key and auto increment.

Firstly, i think it can be an laravel problem. I query mysql directly via phpmyadmin. It is same. But only for this product.

Here is my indexes.

enter image description here

Here is my table structure

enter image description here

I repaired my db from plesk also. Nothing change. Sometimes it works correctly.

Error from phpmyadmin

enter image description here

And the weirdest one is, this error occured when i update stock_quantity field. I can update other fields without problems.

I noticed a mysql bug while searching MySQL Bug: https://bugs.mysql.com/bug.php?id=68360

What should i do ?


解决方案


I solved problem. (Mysql Error Handling is not good. Descriptions must describe the situation better)

I had a trigger for stock_quantity. If a product sold out and get in stock again. I'm sending mail to customers. In that table(products_notify) product_id is unique. And the products which has ids on products_notify fails.

Thanks @Rodrane



所属网站分类: 技术文章 > 问答

作者:黑洞官方问答小能手

链接:http://www.phpheidong.com/blog/article/546154/aadfd9d46130654c1edc/

来源:php黑洞网

任何形式的转载都请注明出处,如有侵权 一经发现 必将追究其法律责任

3 0
收藏该文
已收藏

评论内容:(最多支持255个字符)