mint 0 Posted July 17, 2012 Report Share Posted July 17, 2012 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. Quote Link to post Share on other sites
mint 0 Posted July 17, 2012 Author Report Share Posted July 17, 2012 Now the problem is solved Quote Link to post Share on other sites
Larry 428 Posted July 18, 2012 Report Share Posted July 18, 2012 It'd be nice if you posted how the problem was solved, so that others might benefit. Quote Link to post Share on other sites
mint 0 Posted July 21, 2012 Author Report Share Posted July 21, 2012 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'])) . Quote Link to post Share on other sites
Larry 428 Posted July 23, 2012 Report Share Posted July 23, 2012 Okay. Thanks for sharing that. Quote Link to post Share on other sites
Recommended Posts
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.