title: Insert or update in magento
body: <p>I am inserting rows in a table like this in magento :</p>
  
  <pre><code>$table = Mage::getSingleton('core/resource')-&gt;getTableName('table_name');
  
  $write = Mage::getSingleton('core/resource')-&gt;getConnection('core_write');
  $write-&gt;insertMultiple($table,$rows);
  </code></pre>
  
  <p><code>$rows</code> is the data that I am inserting its a 2D array, I have a primary key <code>'entity_id'</code> and another column <code>order_id</code> which have unique constraint.</p>
  
  <p>Before inserting I want to check if order_id is present in table, if there is a row with <code>order_id</code> then update other wise insert.</p>
  
  <p>I found <code>insertMultiple</code> which throws error if i insert a duplicate <code>order_id</code>. How can I do insert or update based on unique constraint column in table. Thanks</p>
  
  <p>Edit :</p>
  
  <p>I need some think like :</p>
  
  <pre><code>INSERT INTO table (a,b,c) VALUES (1,2,3) ON DUPLICATE KEY UPDATE c=c+1;
  </code></pre>