Jump to content
Larry Ullman's Book Forums

Recommended Posts

I am unable to create a user through the application, I am getting the exception that

CDbCommand failed to execute the SQL statement: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '2001128' for key 'PRIMARY'. The SQL statement executed was: INSERT INTO `tbl_user` (`id`, `name`, `surname`, `username`, `password`, `access`, `email`, `contact`) VALUES (:yp0, :yp1, :yp2, :yp3, :yp4, :yp5, :yp6, :yp7)

 

But I checked the database there was no entry for that primary key, also only the primary gets inserted into the database after submitting the form. I have created a permission hierarchy using rbac. A superadmin can create admin and normaluser, a admin1

can create only normaluser.

Link to post
Share on other sites

The problem was that there was a drop down list which already had some value and whenever some value was entered in the ID(Primary Key) field it automatically got stored in the database with ID value and drop down list value because the create action method in UserController class checks for the

_POST['User'] 

, I think as the two fields were set, it automatically updates the database so whenever the submit button was clicked there was a duplicate value for the primary key and a exception was generated, so I changed the code to check both, is the form fields been entered and the submit button clicked

if(isset($_POST['User']) && isset($_REQUEST['cu']))

.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...