Ich baue ein PHP-Skript, das eine CSV aus einer Mysql-Tabelle ausgibt, aber es speichert die Datei jedes Mal in mysql/data/export.csv
Pfad anstelle der angegebenen. Was mache ich falsch ? Ich benutze XAMPP lokalen Server.Falscher Mysql OUTFILE-Pfad in XAMPP
PHP CODE:
<?php
require_once __DIR__ . DIRECTORY_SEPARATOR . "master.php";
$export_path = __DIR__ . DIRECTORY_SEPARATOR . "export" . DIRECTORY_SEPARATOR . "export.csv";
$query = <<<SQL
SELECT op,cid,lac,rnc,lat,lng,ratio,data,rfu
FROM cells
INTO OUTFILE '?'
FIELDS TERMINATED BY ';'
LINES TERMINATED BY '\n';
SQL;
$statement = db()->prepare($query);
$statement->execute([$export_path]);
header('Content-Type: application/csv');
header('Content-Disposition: attachment; filename="export.csv";');
readfile($export_path);
P. S. wenn ich die Zitate aus dem Fragezeichen in INTO OUTFILE '?'
entferne es gibt mir diese Fehlermeldung:
PDO::prepare(): SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '? FIELDS TERMINATED BY ';' LINES TERMINATED BY ' '' at line 3 in C:\xampp\htdocs\celldb\export.php on line 14
Es ist seltsam, weil 'LOAD DATA INFILE' vorbereitete Anweisungen unterstützt –