Yii Framework Forum: Load data local infile MySQL does not work - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Load data local infile MySQL does not work Rate Topic: -----

#1 User is offline   z515 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 30-January 12

Posted 30 January 2012 - 11:46 AM

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.
0

#2 User is offline   Da:Sourcerer 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,222
  • Joined: 30-March 11
  • Location:Berlin, Germany

Posted 30 January 2012 - 11:52 AM

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
  ),
),

programmer /ˈprəʊgramə/, noun: a device that converts ►coffee into ►code
0

#3 User is offline   z515 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 30-January 12

Posted 30 January 2012 - 12:22 PM

View PostDa:Sourcerer, on 30 January 2012 - 11:52 AM, said:

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.
0

#4 User is offline   Da:Sourcerer 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,222
  • Joined: 30-March 11
  • Location:Berlin, Germany

Posted 30 January 2012 - 01:56 PM

Hm, how do you mean, you haven't succeeded? What error does this approach give you?
programmer /ˈprəʊgramə/, noun: a device that converts ►coffee into ►code
0

#5 User is offline   Led 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 201
  • Joined: 16-January 12

Posted 02 May 2013 - 12:16 PM

View Postz515, on 30 January 2012 - 12:22 PM, said:

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.


did you find an solution to your problem
0

#6 User is offline   Snacob 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 13-July 11

Posted 14 May 2013 - 05:30 PM

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
0

#7 User is offline   raowl 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 26-February 10

Posted 06 February 2014 - 04:10 PM

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

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users