Easy database question

I want it to use a regular mysql database with PDO_MYSQL driver so I put this in the config




                'db'=>array(

		    'class' =>'CDbConnection',

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

		    'username'=>'root', 

 

                 ),



Then I went into the yiic shell tool and tried to create a model. This is

what I get.

exception ‘CDbException’ with message ‘CDbCommand failed to execute the SQL statement: SQLSTATE[HY000]: General error: 2030 This command is not supported in the prepared statement protocol yet’ in /path/to/yii/framework/db/CDbCommand.php:322

I don’t want to hear it only works with SQLITE!

This one SHOULD be trivial. Pls tell me how to fix.

Add ‘emulatePrepare’=>true to the configuration.

Thank you that worked. I never heard of anything like that, it’s not in the Guide, and I have used mySQL for years and PDO for quite a while too. Since all I’m doing at the moment is running the Yii script, it would seem like this attribute would need to be set by anyone using mySQL, i.e. by default.

How should I have known that it was there in the first place and that I needed to turn it on?

The reason you didn’t encounter this problem before is because youdidn’t use the prepared statement feature of PDO which is widely usedin Yii.

Anyway, I have updated the guide about this. This is only needed by some MySQL installations.

I used prepared statements before, but maybe not in this environment. Doesn’t Magento use them? I have a magento install running out of this database server. It would be interesting to know why some installations need it and others don’t. Has it got something to do with the version of the driver you installed? Oh well, I should shut up. :) It works and that’s good.

Hello

I use PHPPDO and have the same problem. This is my connection settings:


'db'=>array(

			'class'=>'application.extensions.PHPPDO.CPdoDbConnection',

			'pdoClass' => 'PHPPDO',

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

			'emulatePrepare' => true,

			'username' => 'root',

			'password' => '',

			'charset' => 'utf8',

		),

On my local machine it works also without ‘emulatePrepare’ but on deployment server - not.

On model creation


 $modelStudent=new Student; 

I see this error: "CDbCommand failed to execute the SQL statement: CDbCommand failed to prepare the SQL statement: SQLSTATE[HY000] [1295] This command is not supported in the prepared statement protocol yet. The SQL statement executed was: SHOW CREATE TABLE student"