I'm not sure if this is a bug, or if I'm just not quite doing something correctly.
Basically I have 3 tables: Product, Category, and ProductCategoryLink.
ProductCategoryLink table has the fields productId and categoryId.
I used the shell command to generate my models and it setup the relation:
'productCategoryLinks' => array(self::HAS_MANY, 'ProductCategoryLink', 'productId'),
Now when I do this in my controller:
$model = Product::model()->findByPk(1);
$links = $model->productCategoryLinks;
I get the error:
PHP Error
Description
Invalid argument supplied for foreach()
Source File
/data/web/vhosts/yii-1.0.6/framework/db/ar/CActiveFinder.php(586)
Now when I wrap the loop with: if(is_array($this->_pkAlias)) { }
I get back the relations that I was expecting and everything works.
Thanks for your help/insight.