duplicate entry error. How to catch? |
I have a table where I am inserting rows. I have created the table with this:
$sql = "CREATE TABLE BC_PR_list_temp( taxyear VARCHAR(10), employee_email VARCHAR(80), employee VARCHAR(80), qualified_dollars int NOT NULL, title varchar(80), role varchar(80), num_BC int NOT NULL, num_PR int NOT NULL, type varchar(4), item varchar(80), dollarsPerBC int NOT NULL, dollarsPerPR int NOT NULL, business_component_string varchar(120), project_string varchar(120), CONSTRAINT OnlyOne UNIQUE (employee_email, item, qualified_dollars) )"; $this->db->query($sql); At some later time I am inserting rows but sometimes insert the same row twice. That is why I put in the Constraint. Now when I try to put in the same row twice, I get this error: Error Number: 1062 Duplicate entry '[email protected]' for key 'BC_PR_list_temp.OnlyOne' That is a correct call to constraint but I want to catch that error and just continue. How do I just ignore that error. Right now the entire program stops!
proof that an old dog can learn new tricks
|
Messages In This Thread |
duplicate entry error. How to catch? - by richb201 - 07-06-2021, 10:52 AM
RE: duplicate entry error. How to catch? - by php_rocs - 07-06-2021, 12:55 PM
RE: duplicate entry error. How to catch? - by richb201 - 07-06-2021, 01:29 PM
RE: duplicate entry error. How to catch? - by richb201 - 07-06-2021, 02:36 PM
RE: duplicate entry error. How to catch? - by richb201 - 07-06-2021, 06:28 PM
RE: duplicate entry error. How to catch? - by ikesela - 07-07-2021, 12:03 AM
RE: duplicate entry error. How to catch? - by richb201 - 07-07-2021, 03:31 AM
|