I am using PHP scripts on my mySQL database. What I have is an inventory of products that is being pulled for a search page. I have this working fine, and my search page is working flawlessly. The only thing I cannot figure out is how to update the stock of each product in the database. I have a new file that needs to match up with the product number and then replace the data in one column of the mysql database. Much like this below
mysql database:
ProductNumber………………ProductStock
12345678………………………………1
New file:
12345678………………5
Basically I need the new file to match with the product number on the mysql and replace the product stock with the new number. All of this in PHP.
You don’t say how many rows you got in that database. Usually individual UPDATEs are pretty slow.
You can
This will be a few orders of magnitude faster.
Update with the syntax to use on mysql :
Note that you need special privileges for LOAD DATA INFILE.
You can also use LOAD DATA INFILE LOCAL (check the docs).
Or, you can parse the file with PHP, generate an INSERT with multi-values in a temp table, and do a joined update. This will be a little slower than LOAD DATA INFILE, but much much faster than doing 27000 queries.