src/ORM/DataObject.php
public function update($data)
    {
        foreach ($data as $key => $value) {
            // Implement dot syntax for updates
            if (strpos($key, '.') !== false) {
                $relations = explode('.', $key);
                $fieldName = array_pop($relations);
                /** @var static $relObj */
                $relObj = $this;
                $relation = null;
                foreach ($relations as $i => $relation) {
                    // no support for has_many or many_many relationships,
                    // as the updater wouldn't know which object to write to (or create)
                    if ($relObj->$relation() instanceof DataObject) {
                        $parentObj = $relObj;
                        $relObj = $relObj->$relation();
                        // If the intermediate relationship objects haven't been created, then write them
                        if ($i < sizeof($relations) - 1 && !$relObj->ID || (!$relObj->ID && $parentObj !== $this)) {
                            $relObj->write();
                            $relatedFieldName = $relation . "ID";
                            $parentObj->$relatedFieldName = $relObj->ID;
                            $parentObj->write();
                        }
                    } else {
                        user_error(
                            "DataObject::update(): Can't traverse relationship '$relation'," .
                            "it has to be a has_one relationship or return a single DataObject",
                            E_USER_NOTICE
                        );
                        // unset relation object so we don't write properties to the wrong object
                        $relObj = null;
                        break;
                    }
                }

                if ($relObj) {
                    $relObj->$fieldName = $value;
                    $relObj->write();
                    $relatedFieldName = $relation . "ID";
                    $this->$relatedFieldName = $relObj->ID;
                    $relObj->flushCache();
                } else {
                    $class = static::class;
                    user_error("Couldn't follow dot syntax '{$key}' on '{$class}' object", E_USER_WARNING);
                }
            } else {
                $this->$key = $value;
            }
        }
        return $this;
    }
public function update($data)
    {
        foreach ($data as $key => $value) {
            // Implement dot syntax for updates
            if (strpos($key, '.') !== false) {
                $relations = explode('.', $key);
                $fieldName = array_pop($relations);
                /** @var static $relObj */
                $relObj = $this;
                $relation = null;
                foreach ($relations as $i => $relation) {
                    // no support for has_many or many_many relationships,
                    // as the updater wouldn't know which object to write to (or create)
                    if ($relObj->$relation() instanceof DataObject) {
                        $parentObj = $relObj;
                        $relObj = $relObj->$relation();
                        // If the intermediate relationship objects haven't been created, then write them
                        if ($i < sizeof($relations) - 1 && !$relObj->ID || (!$relObj->ID && $parentObj !== $this)) {
                            $relObj->write();
                            $relatedFieldName = $relation . "ID";
                            $parentObj->$relatedFieldName = $relObj->ID;
                            $parentObj->write();
                        }
                    } else {
                        user_error(
                            "DataObject::update(): Can't traverse relationship '$relation'," .
                            "it has to be a has_one relationship or return a single DataObject",
                            E_USER_NOTICE
                        );
                        // unset relation object so we don't write properties to the wrong object
                        $relObj = null;
                        break;
                    }
                }

                if ($relObj) {
                    $relObj->$fieldName = $value;
                    $relObj->write();
                    $relatedFieldName = $relation . "ID";
                    $this->$relatedFieldName = $relObj->ID;
                    $relObj->flushCache();
                } else {
                    $class = static::class;
                    user_error("Couldn't follow dot syntax '{$key}' on '{$class}' object", E_USER_WARNING);
                }
            } else {
                $this->$key = $value;
            }
        }
        return $this;
    }
public function update ( $ data ) { foreach ( $ data as $ key => $ value ) { // Implement dot syntax for updates if ( strpos ( $ key , '.' ) !== false ) { $ relations = explode ( '.' , $ key ) ; $ fieldName = array_pop ( $ relations ) ; /** @var static $relObj */ $ relObj = $ this ; $ relation = null ; foreach ( $ relations as $ i => $ relation ) { // no support for has_many or many_many relationships, // as the updater wouldn't know which object to write to (or create) if ( $ relObj -> $ relation ( ) instanceof DataObject ) { $ parentObj = $ relObj ; $ relObj = $ relObj -> $ relation ( ) ; // If the intermediate relationship objects haven't been created, then write them if ( $ i < sizeof ( $ relations ) - 1 && ! $ relObj -> ID || ( ! $ relObj -> ID && $ parentObj !== $ this ) ) { $ relObj -> write ( ) ; $ relatedFieldName = $ relation . "ID" ; $ parentObj -> $ relatedFieldName = $ relObj -> ID ; $ parentObj -> write ( ) ; } } else { user_error ( "DataObject::update(): Can't traverse relationship '$relation'," . "it has to be a has_one relationship or return a single DataObject" , E_USER_NOTICE ) ; // unset relation object so we don't write properties to the wrong object $ relObj = null ; break ; } } if ( $ relObj ) { $ relObj -> $ fieldName = $ value ; $ relObj -> write ( ) ; $ relatedFieldName = $ relation . "ID" ; $ this -> $ relatedFieldName = $ relObj -> ID ; $ relObj -> flushCache ( ) ; } else { $ class = static :: class ; user_error ( "Couldn't follow dot syntax '{$key}' on '{$class}' object" , E_USER_WARNING ) ; } } else { $ this -> $ key = $ value ; } } return $ this ; }
Update a number of fields on this object, given a map of the desired changes.

The field names can be simple names, or you can use a dot syntax to access $has_one relations.
For example, array("Author.FirstName" => "Jim") will set $this->Author()->FirstName to "Jim".

Doesn't write the main object, but if you use the dot syntax, it will write()
the related objects that it alters.

When using this method with user supplied data, it's very important to
whitelist the allowed keys.

@param array $data A map of field name to data values to update.
@return DataObject $this
Update a number of fields on this object given a map of the desired changes .