Relational Active Record


I'm having some trouble with relations in Yii. I updated Yii to 1.0.2 after I encountered the error, but alas, the problem remains.

I have two models, Image and ImageFolder. The Image has an attribute imageFolder that points to the id of its ImageFolder.

In ImageFolder I specify

'images'=>array(self::HAS_MANY, 'Image', 'imageFolder')

and in Image I specify

'imageFolder'=>array(self::BELONGS_TO, 'ImageFolder', 'id')

in the relations() return array.

This however results in:

PHP Error


Invalid argument supplied for foreach()

Source File


_pkAlias seems to be null.

Do you have PK defined in your tables?

Damnit, that's it, one primary key was missing. Thanks again qiang.