steelmanronald06 Posted July 29, 2010 Share Posted July 29, 2010 Using codeigniter and having an issue: $sql = "LOAD DATA LOCAL INFILE '".$_SERVER['DOCUMENT_ROOT']."/junk/2010-07-19_ddna_current_APJ.csv' INTO TABLE `pulled_openx_clicks` FIELDS TERMINATED BY '\\t' ENCLOSED BY '\"' ESCAPED BY '\\' LINES TERMINATED BY '\\n' IGNORE 1 LINES"; $data['MyError'] = $this->db->query($sql); Error Number: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '\n' IGNORE 1 LINES' at line 1 LOAD DATA LOCAL INFILE '/var/www/vhosts/sapkdm.com/subdomains/openx/httpdocs/junk/2010-07-19_ddna_current_APJ.csv' INTO TABLE `pulled_openx_clicks` FIELDS TERMINATED BY '\t' ENCLOSED BY '"' ESCAPED BY '\' LINES TERMINATED BY '\n' IGNORE 1 LINES Any insight on this would be great. Also note that where i'm doing terminated by for fields and lines, it is using \\t and \\n. I did have this set to \t and \n, but then the error read like this: Error Number: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' IGNORE 1 LINES' at line 1 LOAD DATA LOCAL INFILE '/var/www/vhosts/sapkdm.com/subdomains/openx/httpdocs/junk/2010-07-19_ddna_current_APJ.csv' INTO TABLE `pulled_openx_clicks` FIELDS TERMINATED BY '' ENCLOSED BY '"' ESCAPED BY '\' LINES TERMINATED BY '' IGNORE 1 LINES Quote Link to comment https://forums.phpfreaks.com/topic/209277-load-data-infile/ Share on other sites More sharing options...
steelmanronald06 Posted July 30, 2010 Author Share Posted July 30, 2010 *bump* Quote Link to comment https://forums.phpfreaks.com/topic/209277-load-data-infile/#findComment-1093155 Share on other sites More sharing options...
Maq Posted July 30, 2010 Share Posted July 30, 2010 You were closer the first time except you were missing a value for the TERMINATED BY. Try this: $sql = "LOAD DATA LOCAL INFILE '".$_SERVER['DOCUMENT_ROOT']."/junk/2010-07-19_ddna_current_APJ.csv' INTO TABLE `pulled_openx_clicks` FIELDS TERMINATED BY '\t' ENCLOSED BY '\"' ESCAPED BY '\\' LINES TERMINATED BY '\n' IGNORE 1 LINES"; Quote Link to comment https://forums.phpfreaks.com/topic/209277-load-data-infile/#findComment-1093172 Share on other sites More sharing options...
steelmanronald06 Posted July 30, 2010 Author Share Posted July 30, 2010 No dice. I get this error: A Database Error Occurred Error Number: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' IGNORE 1 LINES' at line 3 LOAD DATA LOCAL INFILE '/var/www/vhosts/sapkdm.com/subdomains/openx/httpdocs/junk/2010-07-19_ddna_current_APJ.csv' INTO TABLE `pulled_openx_clicks` FIELDS TERMINATED BY ' ' ENCLOSED BY '"' ESCAPED BY '\' LINES TERMINATED BY ' ' IGNORE 1 LINES Quote Link to comment https://forums.phpfreaks.com/topic/209277-load-data-infile/#findComment-1093206 Share on other sites More sharing options...
steelmanronald06 Posted August 2, 2010 Author Share Posted August 2, 2010 *bump* Quote Link to comment https://forums.phpfreaks.com/topic/209277-load-data-infile/#findComment-1094121 Share on other sites More sharing options...
brianlange Posted August 2, 2010 Share Posted August 2, 2010 Try removing the "escaped by" statement. I removed this and it worked. Not sure why the syntax looks okay. Quote Link to comment https://forums.phpfreaks.com/topic/209277-load-data-infile/#findComment-1094221 Share on other sites More sharing options...
steelmanronald06 Posted August 3, 2010 Author Share Posted August 3, 2010 Okay, so that made the SQL statement valid. Here is what I'm dealing with. If I put the sql code directly into the console method in my controller (you can see this because I left the code but commented it out), it works fine and inserts the data into the database. However if I move the SQL over to a method within the model class, create a method in the controller class to call that model method and then call that controller method within the console method, it only outputs a blank page. Here is a pastebin of both of my classes. Controller is listed first then the model. The main method I'm using is the console method within the controller. http://pastebin.com/R1YPxKDJ Any advice/direction would be great. I feel like it is something small, but I'm just not seeing it. No errors are outputting and no errors are being written to my error log. Quote Link to comment https://forums.phpfreaks.com/topic/209277-load-data-infile/#findComment-1094659 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.