But, even if i have multiple primary keys, in the model i have
public function primaryKey()
{
return 'feature_id';
}
Therefore, shouldn’t AR class look into my table after feature_id as primary key ?
Also, if i have multiple primary keys in a table, how should i fetch by primary key , if not in the way i tried above ? because, honestly it doesn’t make any sense to not work.
//MODEL
public function primaryKey()
{
return array('feature_id, vehicle_id');
}
//CONTROLLER CALL OF MODEL
$vehicleFeature=VehicleFeature::model()->findByPk(array('feature_id'=>(int)$fid,'vehicle_id'=>(int)$vid));
I guess you may not overload primaryKey() method :
This method is meant to be overridden in case when the table is not defined with a primary key (for some legency database). If the table is already defined with a primary key, you do not need to override this method. The default implementation simply returns null, meaning using the primary key defined in the database.(yiiframework.com/doc/api/1.1/CActiveRecord#primaryKey()-detail)
How you solved problem, I faced same error and tried as you typed at previous post. Would you show whole code?. I am confused, where do you define $fid and $vid? In VehicleFeature feature model?