Relations Without Primarykey

I just struggled over a strange behavior with database views and relations for which I couldn’t find any solutions on the web. Database views obviously don’t have primary keys, but that shouldn’t be a problem for the relations defined in the model:

public function relations()


	return array(

		'rELATED' => array(self::HAS_MANY, 'Related', array('RelatedID' => 'RelatedID')),



The SQL is well formed and gets results when it’s queried on the DB server. But the model itself just stays empty as soon as a relation is requested! No Error will be shown or any logs written.


As soon as a fake PK is manually is defined in the model, everything works fine…

public function primaryKey()


	return 'ViewID';


I don’t really get it why the PK should be defined to use relations, but at least I think there should be an error message instead of just nothing.


Yii 1.1.14

Apache/2.2.21 (Win32)

Microsoft SQL Server 2012 (sqlsrv apache module)