大家好,如果你能解决我遇到的这个问题,我真的很感激。基本上我要做的是使用into file
函数将数据从mysql导出到文件中。它适用于本地主机,但不适用于实时服务器,我认为这与服务器路径有关,但无法找到解决方案。下面是代码。
$path = "../etrade_files/Exports/Other/product_media_links.csv";
$enclosed_by = '"';
$sql = "(SELECT 'Product ID','Manufacturer','Part No','Model','URL','Image Name')
UNION
(SELECT product_id,manufacturer,part_no,model,url,image_name
FROM etrade_product_media_links
INTO OUTFILE '$path'
FIELDS TERMINATED BY ','
ENCLOSED BY '$enclosed_by'
LINES TERMINATED BY '\r\n')";
$query = $this->db->query($sql);
etade_file
位于网站的根目录中。
谢谢。
答案 0 :(得分:0)
可能你应该这样做:
$path = "etrade_files/Exports/Other/product_media_links.csv";
$enclosed_by = '"';
$sql = "(SELECT 'Product ID','Manufacturer','Part No','Model','URL','Image Name')
UNION
(SELECT product_id,manufacturer,part_no,model,url,image_name
FROM etrade_product_media_links
INTO OUTFILE '$path'
FIELDS TERMINATED BY ','
ENCLOSED BY '$enclosed_by'
LINES TERMINATED BY '\r\n')";
$query = $this->db->query($sql);
但首先请检查您上传.csv文件的位置。