in reply to Caching and inserting big number of records

Do you want to insert records by big chunks? I think the simplest way it's generate RAW SQL with data, somthing like this:
INSERT INTO employees VALUES ('Hicks','Freddy','crew'), ('Harris','Joel','crew'), ('Davis','Julie','manager');
You just add new values into query and at the end you simply execute it.

Replies are listed 'Best First'.
Re^2: Caching and inserting big number of records
by dsheroh (Monsignor) on Aug 21, 2007 at 14:59 UTC
    Is there a clean way to do this with placeholders (i.e., without having 50 "(?, ?, ?)," lines) or does inserting multiple VALUES lines necessarily condemn you to putting the data directly into the SQL statement?
      No - you have to put in the ? unfortunately. You could minimise it to:
      $sql = 'insert into my_table (x,y,z) values ' . join (',', ('values (' . join(',',('?') x $rows) . ')') x $colum +ns )