Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parameterizing file name in MYSQL LOAD DATA INFILE

Is there a way to dynamically specify a file name in the LOAD DATA INFILE? Can it be parameterized like for instance (syntax may be incorrect) LOAD DATA INFILE '$filename'?

like image 438
Ameya Avatar asked May 14 '10 09:05

Ameya


1 Answers

A citation from MySQL documentation:

The LOAD DATA INFILE statement reads rows from a text file into a table at a very high speed. The file name must be given as a literal string.

That means that it can not be a parameter of a prepared statement. But no one forbids to make the string interpolation while the statement is just a string in your PHP code.

like image 171
newtover Avatar answered Oct 23 '22 05:10

newtover