Saturday, November 23, 2013

laravel pdo load data infile only imports first row."This command is not supported in the prepared statement protocol yet"

"This command is not supported in the prepared statement protocol yet". When I tried to use "load data infile" as a raw query on a table , It failed with this error , and after playing with many parameters in the query and tried many DB methods like DB::raw,DB::statement and DB::select, but nothing change the problem still exist . finally I can run the query but only the first raw was inserted,so The problem is in the query itself and Mysql server cannot under the end of line symbol , Just adding double back slash will solve this issue.
"LOAD DATA LOCAL INFILE 'filename'

                    INTO TABLE `tablename`

                    FIELDS TERMINATED BY ','

                    LINES TERMINATED BY '\\n'

                    (col1,col2,col3)";

No comments:

Post a Comment