I just stumbled on something that is a little bit of a mystery to me.
I have this PHP script which parse a nice little .csv file, get the data written in it and goes on to perform a series of INSERT into a MySQL table.
To make this a litte less obscure, let's say that those files contain IDs that correspond to certain items, and their corresponding price at certain dates. A file usually contains either 1 or 3 different IDs and 50 values at most. The file where there is only 1 item don't cause any trouble, but the ones with three different IDs do.
For example let's say I have in this file, 3 IDs : 10, 20 and 30. I'll have several INSERT queries looking like this one:
INSERT INTO prices(id_item,observation_date,price) VALUES('$id_item','$obs_date','$price'), where $id_item, $obs_date and $price are PHP variables containing the values parsed.
I did check that the queries send to MySQL do have the right format and values put in them (using an echo) but when I check the table, the values for the IDs 10 are here, but not those for the IDs 20 or 30
When I parse those files separetly, the scripts do insert the values in the DB. So I ruled out anything wrong with the PHP script but that still left me so confused. How is this possible? I thought about a saturation of the memory or something like that but I don't think that is the case because the files that are incorrectly parsed are parsed in the middle (ie the first two files are parsed correctly, the 3rd and 4th one are not but the 5th is).
Like I said, I also checked the queries to the DB using the 'echo' function (I just print on the screen the queries passed to MySQL), the result looks like that :
Code: Select all
INSERT INTO prices(id_item,observation_date,price) VALUES('164','2009-05-01','12')
INSERT INTO prices(id_item,observation_date,price) VALUES('164','2009-05-31','15')
INSERT INTO prices(id_item,observation_date,price) VALUES('164','2009-06-01','2')
INSERT INTO prices(id_item,observation_date,price) VALUES('164','2009-06-30','5')
INSERT INTO prices(id_item,observation_date,price) VALUES('432','2009-05-01','52')
INSERT INTO prices(id_item,observation_date,price) VALUES('432','2009-05-31','45')
INSERT INTO prices(id_item,observation_date,price) VALUES('432','2009-06-01','46')
INSERT INTO prices(id_item,observation_date,price) VALUES('432','2009-06-30','20')
INSERT INTO prices(id_item,observation_date,price) VALUES('1223','2009-05-01','32')
INSERT INTO prices(id_item,observation_date,price) VALUES('1223','2009-05-31','35')
INSERT INTO prices(id_item,observation_date,price) VALUES('1223','2009-06-01','29')
INSERT INTO prices(id_item,observation_date,price) VALUES('1223','2009-06-30','25')
[...]
Does anyone have any idea of what's going on?
Thank you!