我想为输出文本文件添加日期和时间。
例如OrderData1506241249,我该怎么办? 我正在使用wamp和mysql工作台来执行此操作。请帮忙。
$sql4 = "
SELECT * FROM FOrder
INTO OUTFILE 'OrderData.txt'
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\r\n';
答案 0 :(得分:0)
要将其添加为列,只需更改您的查询以包含now()函数:
SELECT *, now() as [Current Date] FROM FOrder
如果您希望它只显示一次数据的上方或下方,您可以随时进行联合。假设MyTable有2个字段,id int和name varchar
$sql4 = "
SELECT * FROM FOrder
UNION ALL SELECT 0, 'Report Date: '+cast(now() as char) as [name]
INTO OUTFILE 'OrderData.txt'
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\r\n';
答案 1 :(得分:0)
我认为您的意思是您想要将日期和时间添加到要将输出放入的文件名中。
所以试试这个
$datetime = date('ymdHi');
$sql4 = "
SELECT * FROM FOrder
INTO OUTFILE 'OrderData$datetime.txt'
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\r\n'";