Jump to content
Larry Ullman's Book Forums

Creating User


mint
 Share

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 comment
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 comment
Share on other sites

 Share

×
×
  • Create New...