I’m getting the following error while executing database query:
Error Number: 1062
Duplicate entry '1' for key 1
INSERT INTO `message_template` (`id`, `name`, `subject`, `detail`, `type`,
`status`, `create_date`)
VALUES (1, 'adaa', '', 'dss', 'SMS', 'Active', '2011-08-25 19:34:08')
Filename: C:\AppServ\www\ci\system\database\DB_driver.php
Line Number: 330
How can I get the error number (e.g. 1062) to handlle error?
Thank you
That’s an error coming from database.
You can hide in /application/config/database.php
Else, you might want to take care of it. I suggest just checking if the value already exists:
or, if you have the will to use raw queries, that should be slightly faster (I wouldn’t really worry about a search by ID)
Otherwise, check out DataMapper ORM, so all your database things are automatically taken care of.