RE: [PHP] mySQL LOAD DATA INFILE
| From: | Niklas Lampén | Date: | Tue, 06 Nov 2001 13:12:26 +0000 |
| Subject: | RE: [PHP] mySQL LOAD DATA INFILE | ||
| References: | 1 | Groups: | php.db php.general |
| Request: | Send a blank email to php-db+get-14044@lists.php.net to get a copy of this message | ||
Found the solution:
I had to change row
$fpName = tempnam($dir, "tableData");
to
$fpName = tempnam("", "tableData");
So file will be created to a temporary directory.
Niklas
P.S. :)
-----Original Message-----
From: Niklas Lampén [mailto:niklas.lampen@publico.fi]
Sent: 6. marraskuuta 2001 14:56
To: Php-General; Php-DB
Subject: [PHP] mySQL LOAD DATA INFILE
I have this code:
<?
$dir = getcwd();
$fpName = tempnam($dir, "tableData");
$fp = fopen($fpName, "w");
fputs($fp, $strData);
fclose($fp);
$QueryInsert = "
LOAD DATA INFILE '$fpName'
INTO TABLE feStatics
FIELDS TERMINATED BY '|'
LINES TERMINATED BY '\n'
";
mysql_query($QueryInsert);
print mysql_error();
unlink($fpName);
?>
It returns "Can't get stat of '/www/publico2/tableData0TMRRy' (Errcode:
13)".
I'd put this file into mySQL's database dir, but I have no access there.
Any ideas how to do this? Inserting file row by row would take like
eternity, so that is not a good idea.
Niklas