Edit report at https://bugs.php.net/bug.php?id=55737&edit=1
ID: 55737
Comment by: denis_truffaut at hotmail dot com
Reported by: stefan dot kaifer at hartmann dot info
Summary: LOAD DATA LOCAL INFILE - The used command is not
allowed with this MySQL versio
Status: Not a bug
Type: Bug
Package: MySQL related
Operating System: opensuse 11.0
PHP Version: 5.3.8
Assigned To: mysql
Block user comment: N
Private report: N
New Comment:
To : [email protected]
This bug appears when you use both PDO (pdo_mysql) and mysqlnd (the php mysql
native driver).
The last time I tested PHP 5.4, it was not solved so i tricked the sources to
make it work, before compiling php.
A dirty fix is :
sudo sed -i -e 's/if (mysql_options(H->server,
MYSQL_OPT_LOCAL_INFILE/local_infile = 1;if (mysql_options(H->server,
MYSQL_OPT_LOCAL_INFILE/g' ext/pdo_mysql/mysql_driver.c
Previous Comments:
------------------------------------------------------------------------
[2012-05-04 13:46:45] [email protected]
So, what is this report about? If it's on ext/mysql, I call it not a bug. Thus,
closing. If config is correct, things work just fine.
----------
$host = "localhost:/var/run/mysql/mysql.sock";
$user = "root";
$pass = "";
$flags = 128;
$db = "test";
printf("PHP %s\n", PHP_VERSION);
$file = getcwd() . DIRECTORY_SEPARATOR . "foo.txt";
if (!($fp = fopen($file, "w")))
die(sprintf("Failed to open '%s' for writing\n", $file));
if (!fwrite($fp, "1;a\n") || !fwrite($fp, "2;b\n"))
die(sprintf("Failed to write to '%s'\n", $file));
fclose($fp);
$sql = sprintf("LOAD DATA LOCAL INFILE '%s' INTO TABLE test FIELDS TERMINATED
BY ';'", $file);
if (!($mysql = mysql_connect($host, $user, $pass, true, $flags)))
die(sprintf("Failed to connect to MySQL\n"));
printf("MySQL %s\n", mysql_get_server_info($mysql));
mysql_select_db($db);
mysql_query("DROP TABLE IF EXISTS test", $mysql);
mysql_query("CREATE TABLE test(id INT, col_a VARCHAR(255))", $mysql);
mysql_close($mysql);
if (!($mysql = mysql_connect($host, $user, $pass, true, $flags)))
die(sprintf("Failed to connect to MySQL\n"));
if (!mysql_db_query($db, $sql, $mysql))
die(sprintf("LOAD DATA failed: %s\n", mysql_error($mysql)));
$res = mysql_query("SELECT * FROM test", $mysql);
while ($row = mysql_fetch_row($res))
var_dump($row);
-------- gives -------------
PHP 5.3.12-dev
MySQL 5.5.16-log
array(2) {
[0]=>
string(1) "1"
[1]=>
string(1) "a"
}
array(2) {
[0]=>
string(1) "2"
[1]=>
string(1) "b"
}
------------------------------------------------------------------------
[2012-02-02 14:55:26] stefan dot kaifer at hartmann dot info
Hi
sorry for the late answer: 5.3.4 worked for me, 5.3.4 to 5.3.7 I don't tested!
5.3.8 and 5.3.9 dont't works for me. I've compiled all versions with the same
"configure"-parameters.
I hope, that somebody can solve the problem.
Best reguards
Stefan
------------------------------------------------------------------------
[2011-10-25 19:21:14] richardpq at gmail dot com
I haven't test this functionality before, this is the first time that I tested
it.
@Stefan point that it was working before and now not, but I don't know which
version he use... At the moment I am testing locally so I can put the files in
my
mysql data directory and it works, but I don't know, what I will do when I have
to upload to the server since is not a private server.
------------------------------------------------------------------------
[2011-10-25 18:53:41] [email protected]
Which is the last version of 5.3 which worked for you?
------------------------------------------------------------------------
[2011-10-25 18:36:30] richardpq at gmail dot com
[email protected],
Neither 5.3snv and 5.3.8 snv work, the same problem
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=55737
--
Edit this bug report at https://bugs.php.net/bug.php?id=55737&edit=1