Re: DB package... mysql: LOAD DATA LOCAL INFILE

From: Date: Tue, 08 Mar 2005 15:30:24 +0000
Subject: Re: DB package... mysql: LOAD DATA LOCAL INFILE
References: 1 2  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-17925@lists.php.net to get a copy of this message
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);

« previous php.pear.general (#17925) next »