title: CakePHP: Overwrite existing duplicate data
body: <p>How can I get Cake to use REPLACE INTO instead of INSERT INTO? I have an action that saves data into the database but I don't want to have duplicate entries. The primary keys (id) are unique, if the value already exists I don't want it to be entered as a new row.</p>
  
  <p>The data being saved is also generated dynamically, so exiting with an error would not be appropriate.</p>
  
  <p>EDIT
  Initally the data I'm saving is in a single large array</p>
  
  <pre><code>$data = Array([0] =&gt; 'value1', [1] =&gt; 'value2', [2] =&gt; 'value3') etc
  </code></pre>
  
  <p>I'm trying to loop through this array, saving each value as a new record</p>
  
  <pre><code>foreach ($data as $value) { 
      $save_data['Model'] = array('field' =&gt; $value);
  }
  Classregistry::init('Model')-&gt;saveAll($save_data);
  </code></pre>
  
  <p>I'm using Classregistry because I am saving the data to a different model. Currently this code craps out when trying to insert a duplicate record because 'field' is a unique index. Before using CakePHP I just used the REPLACE INTO syntax without problems. I'd like to achieve something similar in Cake.</p>
  
  <p>The only workaround I have at the moment is to allow duplicates to be entered but only display unique rows by grouping them.</p>