Dear all,
I use the following setup to try out Yii Framework:
Windows XP Pro
Apache 2.2.9
PHP 5.3.0
Yii 1.0.8
MySQL 5.0.67
I follow the example in "The Definitive Guide to Yii 1.0" to create the "testdrive" application. I was able to login and view the list of users in the database.
However, when I tried to update an entry with the following URL, I get the exception shown at the end of my question below:
http://127.0.0.1/yii/test/index.php?r=user/show&id=1
I found a thread in this forum with the similar exception, which is solved by creating primary key. In my case, the primary key has already been created.
What have I missed out?
Thanks in advance.
CDbException
Description
Column name must be either a string or an array.
Source File
C:\DATA\workspace\yii\framework\db\schema\CDbCommandBuilder.php(628)
00616: }
00617: if(count($values)===1)
00618: {
00619: $entries=array();
00620: foreach($values[0] as $name=>$value)
00621: $entries[]=$prefix.$table->columns[$name]->rawName.($value===null?’ IS NULL’:’=’.$value);
00622: return implode(’ AND ',$entries);
00623: }
00624:
00625: return $this->createCompositeInCondition($table,$values,$prefix);
00626: }
00627: else
00628: throw new CDbException(Yii::t(‘yii’,‘Column name must be either a string or an array.’));
00629: }
00630:
00631: /**
00632: * Generates the expression for selecting rows with specified composite key values.
00633: * @param CDbTableSchema the table schema
00634: * @param array list of primary key values to be selected within
00635: * @param string column prefix (ended with dot)
00636: * @return string the expression for selection
00637: * @since 1.0.4
00638: */
00639: protected function createCompositeInCondition($table,$values,$prefix)
00640: {
Stack Trace
#0 C:\DATA\workspace\yii\framework\db\schema\CDbCommandBuilder.php(429): CDbCommandBuilder->createInCondition(Object(CMysqlTableSchema), NULL, Array)
#1 C:\DATA\workspace\yii\framework\db\ar\CActiveRecord.php(1464): CDbCommandBuilder->createPkCriteria(Object(CMysqlTableSchema), ‘1’, ‘’, Array)
#2 C:\DATA\workspace\yii\test\protected\controllers\UserController.php(163): CActiveRecord->findByPk(‘1’)
#3 C:\DATA\workspace\yii\test\protected\controllers\UserController.php(58): UserController->loadUser()
#4 C:\DATA\workspace\yii\framework\web\actions\CInlineAction.php(32): UserController->actionShow()
#5 C:\DATA\workspace\yii\framework\web\CController.php(300): CInlineAction->run()
#6 C:\DATA\workspace\yii\framework\web\filters\CFilterChain.php(129): CController->runAction(Object(CInlineAction))
#7 C:\DATA\workspace\yii\framework\web\filters\CFilter.php(41): CFilterChain->run()
#8 C:\DATA\workspace\yii\framework\web\CController.php(952): CFilter->filter(Object(CFilterChain))
#9 C:\DATA\workspace\yii\framework\web\filters\CInlineFilter.php(59): CController->filterAccessControl(Object(CFilterChain))
#10 C:\DATA\workspace\yii\framework\web\filters\CFilterChain.php(126): CInlineFilter->filter(Object(CFilterChain))
#11 C:\DATA\workspace\yii\framework\web\CController.php(283): CFilterChain->run()
#12 C:\DATA\workspace\yii\framework\web\CController.php(257): CController->runActionWithFilters(Object(CInlineAction), Array)
#13 C:\DATA\workspace\yii\framework\web\CWebApplication.php(332): CController->run(‘show’)
#14 C:\DATA\workspace\yii\framework\web\CWebApplication.php(120): CWebApplication->runController(‘user/show’)
#15 C:\DATA\workspace\yii\framework\base\CApplication.php(134): CWebApplication->processRequest()
#16 C:\DATA\workspace\yii\test\index.php(11): CApplication->run()