Hi All,
This is part of a PHP script that I am wanting to use to automate some daily data exports. The problem I am having, is adding a datestamp to my export file. The script itself works when executed in MySQL but not under PHP. Does anyone have any insight into how I can get this working? The error message I am currently getting is, and the part of php script I am running can be seen below.
$sql1 = "SET @exportfile =
CONCAT(SELECT
'FIELD_1'
, 'FIELD_2'
, ....
UNION ALL
SELECT * FROM mydatabasetable INTO OUTFILE 'E:/Data/exports/DailyExport/myexportfile"
, DATE_FORMAT( NOW(), '%Y%m%d')
, ".csv'
FIELDS TERMINATED BY ','
ENCLOSED BY ''''
LINES TERMINATED BY '\r\n'
);";
$sql2 = "PREPARE processing FROM @exportfile;";
$sql3 = "EXECUTE processing;";
$sql4 = "DROP PREPARE processing;";
Any help here is greatly appreciated.