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