Hello fellow Yii'ers!
I am running an xampp stack on top of a windows machine for local development and attempting to load large batch files into mysql. I have been essentially following this tutorial:
Importing CSV file to mysql table using "LOAD DATA" command
My code looks a little like this:
When I load the file I get this error:
"PDOStatement::execute() [<a href='pdostatement.execute'>pdostatement.execute</a>]: LOAD DATA LOCAL INFILE forbidden"
I have followed the advice given here Load data local infile MySQL does not work by adding the attribute option into my db connection as such:
I have also added the following line to my.ini file, under [mysqld]:
These setting have not changed the error at all. I have searched for an answer, but I have not been able to resolve the issue. I should also mention, if I run the same sql statement within phpMyAdmin, it works flawlessly. I'm hoping someone more knowledgeable about this issue may be able to assist me. Thank you!
I am running an xampp stack on top of a windows machine for local development and attempting to load large batch files into mysql. I have been essentially following this tutorial:
Importing CSV file to mysql table using "LOAD DATA" command
My code looks a little like this:
$sql = 'LOAD DATA LOCAL INFILE "' . $tempLoc . '" INTO TABLE charges FIELDS TERMINATED BY "," ENCLOSED BY "\'" LINES TERMINATED BY "\\n" ( id, loc, chgs, post_dt )'; $connection = Yii::app()->db; $transaction = $connection->beginTransaction(); try { $connection->createCommand($sql)->execute(); $transaction->commit(); } catch (Exception $e) { // an exception is raised if a query fails print_r($e); exit; $transaction->rollBack(); }
When I load the file I get this error:
"PDOStatement::execute() [<a href='pdostatement.execute'>pdostatement.execute</a>]: LOAD DATA LOCAL INFILE forbidden"
I have followed the advice given here Load data local infile MySQL does not work by adding the attribute option into my db connection as such:
'db'=>array( 'connectionString' => 'mysql:host=localhost;dbname=...', 'username' => '...', 'password' => '...', 'attributes'=>array( PDO::MYSQL_ATTR_LOCAL_INFILE ), ),
I have also added the following line to my.ini file, under [mysqld]:
local-infile=1
These setting have not changed the error at all. I have searched for an answer, but I have not been able to resolve the issue. I should also mention, if I run the same sql statement within phpMyAdmin, it works flawlessly. I'm hoping someone more knowledgeable about this issue may be able to assist me. Thank you!