First, thanks to all PEAR developers! I am looking for a way to
successfully execute the following SQL via the pear DB package:
LOAD DATA INFILE 'tmp/myfile.csv' INTO TABLE my_table FIELDS
TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' ESCAPED BY '\\' LINES
TERMINATED BY '\r\n'
The DB packages converts this (escapes the quotes and slashes) to this:
LOAD DATA INFILE "tmp/myfile.csv"
INTO TABLE my_table
FIELDS TERMINATED BY ","
OPTIONALLY ENCLOSED BY \'"\'
ESCAPED BY "\\"
LINES TERMINATED BY "\\r\\n"
Is there a way to use the DB object with out having it touch the query I
put in the $db->query()?
Perhaps you're submitting this via a web form and magic_quotes is on?
Show some code.
Here is the code, and we are not using a form. I thought it might be magic_quotes too. I did some investigation after I wrote the email... Got a little closer but still having some problems.
$sql = " LOAD DATA INFILE \"!\"
INTO TABLE !
FIELDS TERMINATED BY \",\"
OPTIONALLY ENCLOSED BY '\"'
ESCAPED BY \"\\\"
LINES TERMINATED BY \"\r\n\""
. $this->getIgnoreSyntax();
$val = array($this->getFile(),$this->getTable());
$result =& $this->db->query($sql,$val);