Integrity constraint violation: 1062 Duplicate entry '1' for key 'PRIMARY'

后端 未结 4 1788
旧时难觅i
旧时难觅i 2021-02-19 09:23

I have a databse problem where i get Integrity constraint violation: 1062. I tried some things on my own but it didtn work so now i am asking you guys to see if you people can h

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-19 09:58

    When inserting into a table with an auto increment field, the auto increment field itself should not be specified at all.

    Query("INSERT INTO prod_categorie (categorieID, parentID) VALUES (?, ?)", array($chkParent, $txtParentCategorie));
                                       ^^^^^^^^^^^                    ^             ^^^^^^^^^^
    

    Should be just

    Query("INSERT INTO prod_categorie (parentID) VALUES (?)", array($txtParentCategorie));
    

    Just added as answer from comment discussion to allow accept and finishing the question.

提交回复
热议问题