Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 07/11/2021 in all areas

  1. $product_stock, $product_status and $product_id are all nemeric so do not put them in side quotes within your query string. Any extra whitespace will prevent a match. It is more efficient to prepare a query once and bind the parameters then execute it within the loop. You are doing it the slowest way possible. However, the most efficient way would be to put the data in array then use a single multi-record insert. $fp = fopen('myfile.csv', 'r'); $rec = fgetcsv($fp); // header rec while ($rec = fgetcsv($fp)) { $data[] = vsprintf("(%d, %d)", $rec); // store in array } // now insert/update the array data into the table $conn->query("INSERT INTO products (id, product_stock) VALUES " . join(',', $data) . " ON DUPLICATE KEY UPDATE product_stock = VALUES(product_stock) , product_status = 1 ");
    1 point
This leaderboard is set to New York/GMT-04:00
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.