I have a php page that uploads a txt file into a table,
$sql = "LOAD DATA LOCAL INFILE 'data.txt'
REPLACE
INTO TABLE tempdirtySI
FIELDS TERMINATED BY '\t'
LINES TERMINATED BY '\n'
IGNORE 1 LINES
";
I want to run a trigger to run after all the data is imported that consists of this code.
UPDATE tempdirtysi
SET TIMESTAM = DATE_FORMAT(STR_TO_DATE(TIMESTAM, '%m/%d/%Y %H:%i:%s'), '%Y-%m-%d %H:%i:%s');
INSERT INTO temploadsi
SELECT * FROM tempdirtysi;
TRUNCATE tempdirtysi;
How do I go about this? I tried to spit the update and the insert into two trigger and that only allows one row to be imported. I also tried to do the update in a php page and have the insert run after update, but that also only runs 1 row.
Maybe there is another way to automate this process
IMHO you don’t need a trigger for this. Just execute your sql commands sequentially from your PHP code.