Entity Attribute Value

I was following the yii blog example and was not sure if I missed a step or if there is another alternative than having to declare constants for the values in the lookup table. As I understand it, the lookup table follows a EAV or OTLT concept. For a table with only a few types such as the lookup table example, declaring constants in the model may be fine but as for a table that may include many values (i.e product attributes), it is impractical to declare all possible values as constants. Any ideas or possible alternative solutions?

What do you mean with "declare values as constants?"

In the Yii blog tutorial under the section, "Customizing Post Model" (link: http://www.yiiframework.com/doc/blog/1.1/en/post.model), there is a subsection titled, "4. Representing Status in Text". Within this section the author describes the table, "tbl_lookup" which contains status values for the Comment table and the Post table. After modifying the Lookup model class in order to access the text values(as oppose to the integer values), the author also modifies the class Post extends CActiveRecord with the following:







This I believe is done to later display the lookup table values within a form with something like:

<?php echo $form->dropDownList($model,‘status’,Lookup::items(‘PostStatus’)); ?>.

My question above refered to the fact that it looks as if I have to declare constants in order to get a drop down to display the correct values whenever a database table follows an Entity-Attribute-Value format.

In searching other forums, I found the following could possibly work:

<?php echo $form->dropDownList($model,‘status’, CHtml::listData(Lookup::model()->findAll(), ‘id’, ‘name’)); ?>

However, this displays a drop down list with all values within the tbl_lookup table and not just those values where type=PostStatus.

Hope this clears up my question a little better. I am new to both MVC as well as Yii, please let me make myself a little more clear.