php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #67475 load data local infile fails with pdo_mysql, works with mysqli
Submitted: 2014-06-19 09:13 UTC Modified: 2020-12-11 10:42 UTC
Votes:3
Avg. Score:4.3 ± 0.9
Reproduced:3 of 3 (100.0%)
Same Version:3 (100.0%)
Same OS:1 (33.3%)
From: jaroslav at thinline dot cz Assigned:
Status: Duplicate Package: PDO MySQL
PHP Version: 5.5.13 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
35 + 4 = ?
Subscribe to this entry?

 
 [2014-06-19 09:13 UTC] jaroslav at thinline dot cz
Description:
------------
Using SQL statement LOAD DATA LOCAL INFILE with PDO doesn't work, an error "SQLSTATE[42000]: Syntax error or access violation: 1148 The used command is not allowed with this MySQL version" is returned even with PDO::MYSQL_ATTR_LOCAL_INFILE set to 1 in constructor.

When trying the same with mysqli extension however, everything is executed correctly and test table is filled with data.

PHP is running on Debian Wheezy, using package from dotdeb.org

Test script:
---------------
// Non-functional with PDO
try {
  $con = new PDO("mysql:host=127.0.0.1;dbname=testdb", "user", "pass",
                 array(PDO::MYSQL_ATTR_LOCAL_INFILE => 1));
  $con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  $con->exec('load data local infile \'test.csv\' into table testtable fields terminated by \',\' enclosed by \'"\' escaped by \'"\'');
} catch (PDOException $e) {
  echo $e->getMessage();
}

//Functional with mysqli
$con = mysqli_init();
mysqli_options($con, MYSQLI_OPT_LOCAL_INFILE, true);
mysqli_real_connect($con, '127.0.0.1', 'user', 'pass', 'testdb');
mysqli_query($con, 'load data local infile \'test.csv\' into table testtable fields terminated by \',\' enclosed by \'"\' escaped by \'"\'');



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-02-03 20:13 UTC] phpbugs2012 at joern dot heissler dot de
Duplicate of https://bugs.php.net/bug.php?id=62889
 [2020-12-11 10:42 UTC] nikic@php.net
-Status: Open +Status: Duplicate
 [2020-12-11 10:42 UTC] nikic@php.net
Duplicate of bug #62889 per above comment.
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Thu Jan 21 05:01:23 2021 UTC