How to set 'INSERT IGNORE' in db_insert without db_merge Is anyone know how to set 'INSERT IGNORE' in db_insert? 

I cannot use db_merge because I'm going to insert many rows.

$query = db_insert('table')-&gt;fields(array('foo', 'bar'));
foreach ($rows as $row) {
  $query-&gt;values(array(
    'foo' =&gt; $row-&gt;foo,
    'bar' =&gt; $row-&gt;bar,
  ));
}
$query-&gt;execute();
You've got two options:


Subclass InsertQuery and add that functionality in yourself (it's currently not implemented)
Use db_query() to run a raw SQL string instead. 


The only mention of INSERT IGNORE in the Drupal 7 codebase is in DatabaseConnection_mysql:nextId; it's not actually used, but in its place is a raw query string containing ON DUPLICATE KEY UPDATE, that gets passed directly to db_query(). 

I may be wrong, but I'd assume that's as good an indication as any that a raw SQL string along with db_query() is the way to go.