Hi,
I am sorry if this problem has been already mentioned and solved by another member, but I am also following the Agile Web book by Jeff, and I am in chapter 6 and also seem to be stuck on an error that Yii produces. I am currently using Yii Framework 1.1.7, which is the latest stable version as of today. It seems that my problem is slightly different from the previous member’s (Sasori’s) issue, so I’ve decided to post this problem I am having.
I’ve just finished the PhpUnit testing described on page 126 (phpunit unit/ProjectTest.php), and it passed. However, when I tried to access the URL (localhost/trackstar/index.php?r=project), it gives me an error. Here is the copy of what it says:
CException
Property "Project.type_id" is not defined.
C:\Documents and Settings\kevin\My Documents\www\yii_1.1.7.r3135\framework\db\ar\CActiveRecord.php(128)
116 */
117 public function __get($name)
118 {
119 if(isset($this->_attributes[$name]))
120 return $this->_attributes[$name];
121 else if(isset($this->getMetaData()->columns[$name]))
122 return null;
123 else if(isset($this->_related[$name]))
124 return $this->_related[$name];
125 else if(isset($this->getMetaData()->relations[$name]))
126 return $this->getRelated($name);
127 else
128 return parent::__get($name);
129 }
130
131 /**
132 * PHP setter magic method.
133 * This method is overridden so that AR attributes can be accessed like properties.
134 * @param string $name property name
135 * @param mixed $value property value
136 */
137 public function __set($name,$value)
138 {
139 if($this->setAttribute($name,$value)===false)
140 {
Stack Trace
#0
- C:\Documents and Settings\kevin\My Documents\www\yii_1.1.7.r3135\framework\db\ar\CActiveRecord.php(128): CComponent->__get("type_id")
#1
– C:\Documents and Settings\kevin\My Documents\www\trackstar\protected\views\project\_view.php(16): CActiveRecord->__get("type_id")
11 <b><?php echo CHtml::encode($data->getAttributeLabel(‘description’)); ?>:</b>
12 <?php echo CHtml::encode($data->description); ?>
13 <br />
14
15 <b><?php echo CHtml::encode($data->getAttributeLabel(‘type_id’)); ?>:</b>
16 <?php echo CHtml::encode($data->type_id); ?>
17 <br />
18
19 <b><?php echo CHtml::encode($data->getAttributeLabel(‘status_id’)); ?>:</b>
20 <?php echo CHtml::encode($data->status_id); ?>
21 <br />
What could be wrong? It seems like there is something wrong with CActiveRecord.php or _view.php file. Is this also the problem due to the Yii version difference? I’d greatly appreciate it if you could help me solve this problem.
Thank you.
Kevin