[blog tutorial] CDbCommand failed to execute the SQL statement

Ok i was learning yii following the guide you posted about creating a blog application.

I was on this step: http://www.yiiframew…og/portlet.menu

and when i finished it i tryed to test my application.

I'm using mySQL like dbms and i configured my config/main.php like this:



'db'=>array(


			'class'=>'CDbConnection',


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


			'username'=>'myusername',


			'password'=>'mypassword',


		),


This is the error when i try to login with demo/demo login data.

Quote

CDbException

Description

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

/home/devhpiu/public_html/yii/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: }

Stack Trace

#0 /home/devhpiu/public_html/yii/framework/db/CDbCommand.php(231): CDbCommand->queryInternal('fetch', 2)

#1 /home/devhpiu/public_html/yii/framework/db/schema/mysql/CMysqlSchema.php(165): CDbCommand->queryRow()

#2 /home/devhpiu/public_html/yii/framework/db/schema/mysql/CMysqlSchema.php(68): CMysqlSchema->findConstraints(Object(CMysqlTableSchema))

#3 /home/devhpiu/public_html/yii/framework/db/schema/CDbSchema.php(73): CMysqlSchema->createTable('User')

#4 /home/devhpiu/public_html/yii/framework/db/ar/CActiveRecord.php(1761): CDbSchema->getTable('User')

#5 /home/devhpiu/public_html/yii/framework/db/ar/CActiveRecord.php(525): CActiveRecordMetaData->__construct(Object(User))

#6 /home/devhpiu/public_html/blog/protected/models/User.php(11): CActiveRecord::model('User')

#7 /home/devhpiu/public_html/blog/protected/components/UserIdentity.php(24): User::model()

#8 /home/devhpiu/public_html/blog/protected/models/LoginForm.php(48): UserIdentity->authenticate()

#9 /home/devhpiu/public_html/yii/framework/validators/CInlineValidator.php(39): LoginForm->authenticate('password', Array)

#10 /home/devhpiu/public_html/yii/framework/validators/CValidator.php(159): CInlineValidator->validateAttribute(Object(LoginForm), 'password')

#11 /home/devhpiu/public_html/yii/framework/base/CModel.php(179): CValidator->validate(Object(LoginForm), NULL)

#12 /home/devhpiu/public_html/blog/protected/controllers/SiteController.php(62): CModel->validate()

#13 /home/devhpiu/public_html/yii/framework/web/actions/CInlineAction.php(32): SiteController->actionLogin()

#14 /home/devhpiu/public_html/yii/framework/web/CController.php(265): CInlineAction->run()

#15 /home/devhpiu/public_html/yii/framework/web/CController.php(243): CController->runAction(Object(CInlineAction))

#16 /home/devhpiu/public_html/yii/framework/web/CController.php(225): CController->runActionWithFilters(Object(CInlineAction), Array)

#17 /home/devhpiu/public_html/yii/framework/web/CWebApplication.php(335): CController->run('login')

#18 /home/devhpiu/public_html/yii/framework/web/CWebApplication.php(123): CWebApplication->runController('site/login')

#19 /home/devhpiu/public_html/yii/framework/base/CApplication.php(170): CWebApplication->processRequest()

#20 /home/devhpiu/public_html/blog/index.php(11): CApplication->run()

#21 {main}

What do you think about it? It's a db configuration problem or what else?

Yes, this is related with your PDO driver. You may add an option 'emulatePrepare'=>true to the db connection setting in the app config.

Ok i will try and give you a feedback :)

I'm moving from mySQL to postgreSQL, have i too use the same trick?

it worked well :)

Anyway i want to advice you: in the guide there's some function called but not implemented and it throws error.

Example: called for the right menu of the user ( logged ).



<ul>


<li><?php echo CHtml::link('Approve Comments', array('comment/list'))


    . ' (' . Comment::model()->pendingCommentCount . ')'; ?></li>


<li><?php echo CHtml::link('Create New Post',array('post/create')); ?></li>


<li><?php echo CHtml::link('Manage Posts',array('post/admin')); ?></li>


<li><?php echo CHtml::linkButton('Logout',array(


    'submit'=>'',


    'params'=>array('command'=>'logout'),


)); ?></li>


</ul>


Comment::model()->pendingCommentCount is not implemented :)

Like for this, many other parts that at the moment i don’t remember well :P