php - Batch Inserts And Prepared Query Error -


OK, so I have to populate an MS Access database table with a result from the MySQL query. It is not difficult at all. This program has been written to me where this template copies the .mdb file to a temporary name and opens it through Odbi No problem yet.

I have noticed that access does not support batch insertion ( VALUES (foo, bar), (second, query), (third query) ). So this means that I need to execute one query per line (potentially have hundreds of thousands rows) In early execution tests, the rate of approximately 900 inserts / second appears in access. With our biggest data set, this could mean minutes' execution time (which is not the end of the world, but it is obviously faster).

So, I tried to test a prepared statement but I'm getting an error ( warning: odbc_execute () [function.odbc-execute]: SQL error: [Microsoft] [ ODBC Microsoft Access Driver] COUNT field incorrect, in SQL State 07001 SQLclose: Duplex ... ..php on row 30 ).

Here is the code I am using (line 30 is odbc_execute ):

  $ sql = 'INSERT in table ([field0 ] [Field 1], [field 2], [field 3], [field 4], [field 5]) value (?,?,?,?,?,?) '; $ Stmt = odbc_prepare ($ conn, $ sql); ($ I = 200001; $ i & lt; 300001; $ i ++) {$ a = array ($ i, "field 1 $", "field 2 $ i", "field 3 $ i", "field 4 $ I ", $ i); Odbc_execute ($ stmt, $ a); }  

So my question is two times. First of all, have I got this error (I checked, and the number matches the field list in the array, which matches the parameter ? markers)? And second, should I bother with it or just use the INSERT statement directly? Like I said, time is not important, but if it is possible, then I would like to reduce as much as possible at that time (again, I can be limited by disk throughput, because 900 operations / sec is already high). .

Thanks

Do you need to line this line? Why not insert all the data at once?


Comments