Load data local infile MySQL does not work

Hello there,

I have a question regarding mysql connection.

I am using ‘Load data local infile’ MySql command.

Unfortunately my provider does not allow to use this command directly.

Instead he suggests to use first the following mysql command for the database connection:

mysql_connect($server, $user, $pass, false, 128); #128 is a constant CLIENT_LOCAL_FILES.

I tried this command and it works. But I would prefer to use Yii tools.

I have been trying to use setAttribute function of the class CDbconnection to establish connection

with an atrribute PDO::MYSQL_ATTR_LOCAL_INFILE set to 1. Unfortunately it did not work.

Can anybody advise me an Yii analogue of the above command mysql_connect($server, $user, $pass, false, 128) to set up connection allowing ‘Load data local infile’ MySql command?

Thank you in advance,

Denis.

DB connections can have a set of special PDO flags within their attributes array. Just modify your config/main.php so your db-stanza looks like this:




'db'=>array(

  'connectionString' => 'mysql:host=localhost;dbname=...',

  'username' => '...',

  'password' => '...',

  'attributes'=>array(

    PDO::MYSQL_ATTR_LOCAL_INFILE

  ),

),



Thank you for the reply. I have tried this approach but did not succeed.

In the source code of CDbConnection ‘‘attributes’’ is a private array. As far as I understand you need

to work through a public function to set some value to this array.

Hm, how do you mean, you haven’t succeeded? What error does this approach give you?

did you find an solution to your problem

If anyone else runs into this issue, I fixed it by adding "=> true" after the attribute.




'db'=>array(

  'connectionString' => 'mysql:host=localhost;dbname=...',

  'username' => '...',

  'password' => '...',

  'attributes'=>array(

    PDO::MYSQL_ATTR_LOCAL_INFILE => true

  ),

),



-Jacob

i have this same problem… someone got it to work ? will appreciate some feedback