Welcome Guest, Not a member yet? Register   Sign In
Silent Inserts
#1

[eluser]yehiasalam[/eluser]
Hi,

I have a unique index on one of my table columns to avoid duplicates, what i want to do is to insert a list of items and ignoring any errors for duplicates:

Code:
$this->db_debug = FALSE;
foreach($interests as &$interest){
  $interest = trim($interest);                        
  $this->Interests_model->insert(array('interest_name' => $interest));
}
$this->db_debug = TRUE;

But I'm still getting

Code:
A Database Error Occurred
Error Number: 1062
Duplicate entry 'playing soccer' for key 2
INSERT INTO `interests` (`interest_name`) VALUES ('playing soccer')

What's wrong with that?

Thanks In Advance
Regards.
Yehia A.Salam


Messages In This Thread
Silent Inserts - by El Forum - 10-07-2009, 10:49 AM
Silent Inserts - by El Forum - 10-07-2009, 11:41 AM
Silent Inserts - by El Forum - 10-07-2009, 04:34 PM
Silent Inserts - by El Forum - 10-07-2009, 07:07 PM
Silent Inserts - by El Forum - 10-08-2009, 12:36 AM



Theme © iAndrew 2016 - Forum software by © MyBB