I have 500 rows in CSV. 400 Is inserted and 401 is duplicate, it does not allow me to insert after 401 the rest. I need to manually find the CSV file and edit it.
But how can i tell Zend_Db adapter, on duplicate continue next one, if next one is also duplicate continue to next one, but do not exit unless all rows are scaned.
Example:
$row = Application_Model_Csv::processFile("/var/tmp/csv.csv");
foreach($row as $k=>$v)
{
$insert =array(
'groups' => $v[0],
'country'=> $v[1],
'name' =>$v[2], /* Unique key */
'url' => $v[3]
);
$this->db->insert("something", $insert);
}
You can use REPLACE instead of INSERT. Zend Framework doesn’t have specific method for this, but you can make a custom query: