如何使用YII框架追踪错误?

时间:2011-10-17 17:45:38

标签: php yii

我正在学习Yii框架,我得到了这个错误,并没有真正指出我正在处理的具体页面,或者据我所知告诉我应该从哪里开始寻找我的问题。

我如何理解这一点?据我所知,我所有的'type_id'引用都是正确输入的。

    CException

Description

Property "Project.type_id" is not defined.

Source File

/Users/user/Dropbox/localhost/yii/framework/db/ar/CActiveRecord.php(107)

00095:      */
00096:     public function __get($name)
00097:     {
00098:         if(isset($this->_attributes[$name]))
00099:             return $this->_attributes[$name];
00100:         else if(isset($this->getMetaData()->columns[$name]))
00101:             return null;
00102:         else if(isset($this->_related[$name]))
00103:             return $this->_related[$name];
00104:         else if(isset($this->getMetaData()->relations[$name]))
00105:             return $this->getRelated($name);
00106:         else
00107:             return parent::__get($name);
00108:     }
00109: 
00110:     /**
00111:      * PHP setter magic method.
00112:      * This method is overridden so that AR attributes can be accessed like properties.
00113:      * @param string property name
00114:      * @param mixed property value
00115:      */
00116:     public function __set($name,$value)
00117:     {
00118:         if($this->setAttribute($name,$value)===false)
00119:         {
Stack Trace

#0 /Users/user/Dropbox/localhost/yii/framework/db/ar/CActiveRecord.php(107): CComponent->__get('type_id')
#1 /Users/user/Dropbox/localhost/trackstar/protected/views/project/_view.php(15): CActiveRecord->__get('type_id')
#2 /Users/user/Dropbox/localhost/yii/framework/web/CBaseController.php(119): require('/Users/user/Dro...')
#3 /Users/user/Dropbox/localhost/yii/framework/web/CBaseController.php(88): CBaseController->renderInternal('/Users/user/Dro...', Array, true)
#4 /Users/user/Dropbox/localhost/yii/framework/web/CController.php(748): CBaseController->renderFile('/Users/user/Dro...', Array, true)
#5 /Users/user/Dropbox/localhost/yii/framework/zii/widgets/CListView.php(215): CController->renderPartial('_view', Array)
#6 /Users/user/Dropbox/localhost/yii/framework/zii/widgets/CBaseListView.php(152): CListView->renderItems()
#7 [internal function]: CBaseListView->renderSection(Array)
#8 /Users/user/Dropbox/localhost/yii/framework/zii/widgets/CBaseListView.php(135): preg_replace_callback('/{(\w+)}/', Array, '{summary}?{sort...')
#9 /Users/user/Dropbox/localhost/yii/framework/zii/widgets/CBaseListView.php(121): CBaseListView->renderContent()
#10 /Users/user/Dropbox/localhost/yii/framework/web/CBaseController.php(174): CBaseListView->run()
#11 /Users/user/Dropbox/localhost/trackstar/protected/views/project/index.php(17): CBaseController->widget('zii.widgets.CLi...', Array)
#12 /Users/user/Dropbox/localhost/yii/framework/web/CBaseController.php(119): require('/Users/user/Dro...')
#13 /Users/user/Dropbox/localhost/yii/framework/web/CBaseController.php(88): CBaseController->renderInternal('/Users/user/Dro...', Array, true)
#14 /Users/user/Dropbox/localhost/yii/framework/web/CController.php(748): CBaseController->renderFile('/Users/user/Dro...', Array, true)
#15 /Users/user/Dropbox/localhost/yii/framework/web/CController.php(687): CController->renderPartial('index', Array, true)
#16 /Users/user/Dropbox/localhost/trackstar/protected/controllers/ProjectController.php(148): CController->render('index', Array)
#17 /Users/user/Dropbox/localhost/yii/framework/web/actions/CInlineAction.php(32): ProjectController->actionIndex()
#18 /Users/user/Dropbox/localhost/yii/framework/web/CController.php(300): CInlineAction->run()
#19 /Users/user/Dropbox/localhost/yii/framework/web/filters/CFilterChain.php(129): CController->runAction(Object(CInlineAction))
#20 /Users/user/Dropbox/localhost/yii/framework/web/filters/CFilter.php(41): CFilterChain->run()
#21 /Users/user/Dropbox/localhost/yii/framework/web/CController.php(999): CFilter->filter(Object(CFilterChain))
#22 /Users/user/Dropbox/localhost/yii/framework/web/filters/CInlineFilter.php(59): CController->filterAccessControl(Object(CFilterChain))
#23 /Users/user/Dropbox/localhost/yii/framework/web/filters/CFilterChain.php(126): CInlineFilter->filter(Object(CFilterChain))
#24 /Users/user/Dropbox/localhost/yii/framework/web/CController.php(283): CFilterChain->run()
#25 /Users/user/Dropbox/localhost/yii/framework/web/CController.php(257): CController->runActionWithFilters(Object(CInlineAction), Array)
#26 /Users/user/Dropbox/localhost/yii/framework/web/CWebApplication.php(320): CController->run('')
#27 /Users/user/Dropbox/localhost/yii/framework/web/CWebApplication.php(120): CWebApplication->runController('project')
#28 /Users/user/Dropbox/localhost/yii/framework/base/CApplication.php(135): CWebApplication->processRequest()
#29 /Users/user/Dropbox/localhost/trackstar/index.php(12): CApplication->run()
#30 {main}
2011-10-17 18:17:18 Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8r DAV/2 PHP/5.3.6 Yii Framework/1.1.2

3 个答案:

答案 0 :(得分:1)

在文件中 /Users/user/Dropbox/localhost/trackstar/protected/views/project/_view.php 在第15行 有一些像$ project-> type_id的东西 但是在Project模型中没有属性“type_id”

答案 1 :(得分:1)

简短回答

如果Project类没有对象属性$type_id,那么它将检查此模型的db表中是否存在type_id列。

此外,如果仍未找到该列,则会尝试搜索名为getType_id()的方法,此处有解释。

Yii实现PHP Magic方法__get($ name)和__set($ name,$ value),允许您(尤其是在CActiveRecord中)访问从db表中的列生成的属性,或者使用该类从类中的其他常规属性遵循语法。

object->isNewRecord; // '__get()' is called
object->getIsNewRecord(); // regular syntax without magic method

object->isNewRecord = true; // '__set()' is called
object->setIsNewRecord(true);

答案 2 :(得分:1)

问题是您的一个观点认为您的模型具有此属性。 例如,我从模型中删除了一个列,但我正在调用一个视图(_search),这引用了该列:

<?php echo $form->label($model,'thumbnail'); ?>
25 
<?php echo $form->textField($model,'thumbnail',array('size'=>60,'maxlength'=>255)); ?>

我用过:

find . -name "*" | xargs grep -l "my_property"

追踪违规财产