Problems in DB Connection

I'm starting a new application with yii.

On my local machine the connection to MySQL is fine, but when I deply on the server I get the followin error:

CDbCommand failed to execute the SQL statement: SQLSTATE[HY000]: General error: 2030 This command is not supported in the prepared statement protocol yet

Source File

[…] /framework/db/CDbCommand.php(284)

00272:            if($this->_statement instanceof PDOStatement)

00273:                $this->_statement->execute();

00274:            else

00275:                $this->_statement=$this->getConnection()->getPdoInstance()->query($this->getText());

00276:            if($method==='')

00277:                return new CDbDataReader($this);

00278:            $result=$this->_statement->{$method}($mode);

00279:            $this->_statement->closeCursor();

00280:            return $result;

00281:        }

00282:        catch(Exception $e)

00283:        {

00284:            throw new CDbException(Yii::t('yii','CDbCommand failed to execute the SQL statement: {error}',

00285:                array('{error}'=>$e->getMessage())));

00286:        }

00287:    }

00288: }

PHP Version 5.2.0-8+etch11

Any idea of what is wrong?

Thanks in advance.


I forgot, the exception comes from the login page, where I coded the user authentication as:

	$criteria = new CDbCriteria;



	$user = User::model()->find($criteria);

ok, at the moment I found a solution adding the line

$this->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);

to the file CDbConnection.php::open

protected function open()





			throw new CDbException(Yii::t('yii','CDbConnection.connectionString cannot be empty.'));



			$this->_pdo=new PDO($this->connectionString,$this->username,




			<span style='color: orange'>$this-&gt;setAttribute(PDO::ATTR_EMULATE_PREPARES, true);</span> 


		catch(PDOException $e)


			throw new CDbException(Yii::t(&#039;yii&#039;,&#039;CDbConnection failed to open the DB connection: {error}&#039;,





Is there a better solution?



Thank you for reporting this problem. I just added a new property 'emulatePrepare' to CDbConnection. You may configure that in your app config to solve this problem now.