-
Notifications
You must be signed in to change notification settings - Fork 29
Open
Description
To quote from the Yii AR documentation:
In case you need to specify custom PK->FK association you can define it as array('fk'=>'pk'). For composite keys it will be array('fk_c1'=>'pk_с1','fk_c2'=>'pk_c2').
(docblock in source)
Not talking about the composite key case here. Simply using the same syntax to explicitly name single foreign column => single local column.
If you have an AR child class with this:
// model's own primary key is (`nodeId`)
public function relations()
{
return array(
'parentRelationRecord' => array(
self::HAS_ONE,
'ProjectNodeParent',
array('nodeId' => 'nodeId'), // trivial case
),
'status' => array(
self::HAS_ONE,
'Status',
array('id' => 'statusId'),
),
);
}
... saving triggers a PHP warning in EActiveRecordbehavior::afterSave Line #233
229 // update all not anymore related records
230 $criteria=new ECompositeDbCriteria();
231 $criteria->addNotInCondition(CActiveRecord::model($relation[1])->tableSchema->primaryKey, $newPKs);
232 // @todo add support for composite primary keys
233 $criteria->addColumnCondition(array($relation[2]=>$this->owner->getPrimaryKey()));
At this point, PHP is trying to use an array as an array key, which it can't. This causes the warning.
This call is initiated from CActiveRecord::afterSave and the event it triggers.