Prado\Data\ActiveRecord\Relations\TActiveRecordHasMany::updateAssociatedRecords PHP Метод

updateAssociatedRecords() публичный Метод

Updates the associated foreign objects.
public updateAssociatedRecords ( ) : boolean
Результат boolean true if all update are success (including if no update was required), false otherwise .
    public function updateAssociatedRecords()
    {
        $obj = $this->getContext()->getSourceRecord();
        $fkObjects =& $obj->{$this->getContext()->getProperty()};
        $success = true;
        if (($total = count($fkObjects)) > 0) {
            $source = $this->getSourceRecord();
            $fkeys = $this->findForeignKeys($fkObjects[0], $source);
            for ($i = 0; $i < $total; $i++) {
                foreach ($fkeys as $fKey => $srcKey) {
                    $fkObjects[$i]->setColumnValue($fKey, $source->getColumnValue($srcKey));
                }
                $success = $fkObjects[$i]->save() && $success;
            }
        }
        return $success;
    }