Hi,
I got stuck with a Yii bug…
I have an HAS_MANY relation with composite key defined like that :
'precalculated' => array(self::HAS_MANY, 'PrecalculatedUserMoovpoint', array('checkin_id' => 'checkin_id'))
But when I do something like that (findAll, foreach, update) :
$usersEvent = UserEvent::model()->event($eventID)->getmoovpoint(true)->pointsToWin()->findAll();
if ($_POST['action'] == 'validate') {
foreach ($usersEvent as $ue) {
if($ue->partner_validation === null) {
$ue->partner_validation = UserEvent::PARTNER_VALIDATED;
$ue->save() ;
}
}
I got this error :
Illegal offset type (/var/www/vhost/library/App/extensions/awegen/components/EActiveRecordRelationBehavior.php:205)</p>
That corresponds, in EActiveRecordRelationBehavior.php, to :
// @todo add support for composite primary keys
$criteria->addColumnCondition(array($relation[2]=>$this->owner->getPrimaryKey()));
The @todo reflects the issue that I encountered…
$relation[2] is equal to an array that’s why it crashes.
The strange thing is when I do something like that this error does not appear :
$ue = UserEvent::model()->user($id)->event($eventID)->find();
$ue->partner_validation = UserEvent::PARTNER_VALIDATED;
$ue->update();
NOTA BENE :
->pointsToWin()
uses the specific relation "precalculated"
Someone can explain that ? Even correct it ?
Thanks !