src/ORM/DataObject.php
protected function writeManipulation($baseTable, $now, $isNewRecord)
    {
        // Generate database manipulations for each class
        $manipulation = array();
        foreach (ClassInfo::ancestry(static::class, true) as $class) {
            $this->prepareManipulationTable($baseTable, $now, $isNewRecord, $manipulation, $class);
        }

        // Allow extensions to extend this manipulation
        $this->extend('augmentWrite', $manipulation);

        // New records have their insert into the base data table done first, so that they can pass the
        // generated ID on to the rest of the manipulation
        if ($isNewRecord) {
            $manipulation[$baseTable]['command'] = 'update';
        }

        // Make sure none of our field assignment are arrays
        foreach ($manipulation as $tableManipulation) {
            if (!isset($tableManipulation['fields'])) {
                continue;
            }
            foreach ($tableManipulation['fields'] as $fieldName => $fieldValue) {
                if (is_array($fieldValue)) {
                    $dbObject = $this->dbObject($fieldName);
                    // If the field allows non-scalar values we'll let it do dynamic assignments
                    if ($dbObject && $dbObject->scalarValueOnly()) {
                        throw new InvalidArgumentException(
                            'DataObject::writeManipulation: parameterised field assignments are disallowed'
                        );
                    }
                }
            }
        }

        // Perform the manipulation
        DB::manipulate($manipulation);
    }
protected function writeManipulation($baseTable, $now, $isNewRecord)
    {
        // Generate database manipulations for each class
        $manipulation = array();
        foreach (ClassInfo::ancestry(static::class, true) as $class) {
            $this->prepareManipulationTable($baseTable, $now, $isNewRecord, $manipulation, $class);
        }

        // Allow extensions to extend this manipulation
        $this->extend('augmentWrite', $manipulation);

        // New records have their insert into the base data table done first, so that they can pass the
        // generated ID on to the rest of the manipulation
        if ($isNewRecord) {
            $manipulation[$baseTable]['command'] = 'update';
        }

        // Make sure none of our field assignment are arrays
        foreach ($manipulation as $tableManipulation) {
            if (!isset($tableManipulation['fields'])) {
                continue;
            }
            foreach ($tableManipulation['fields'] as $fieldName => $fieldValue) {
                if (is_array($fieldValue)) {
                    $dbObject = $this->dbObject($fieldName);
                    // If the field allows non-scalar values we'll let it do dynamic assignments
                    if ($dbObject && $dbObject->scalarValueOnly()) {
                        throw new InvalidArgumentException(
                            'DataObject::writeManipulation: parameterised field assignments are disallowed'
                        );
                    }
                }
            }
        }

        // Perform the manipulation
        DB::manipulate($manipulation);
    }
protected function writeManipulation ( $ baseTable , $ now , $ isNewRecord ) { // Generate database manipulations for each class $ manipulation = array ( ) ; foreach ( ClassInfo :: ancestry ( static :: class , true ) as $ class ) { $ this -> prepareManipulationTable ( $ baseTable , $ now , $ isNewRecord , $ manipulation , $ class ) ; } // Allow extensions to extend this manipulation $ this -> extend ( 'augmentWrite' , $ manipulation ) ; // New records have their insert into the base data table done first, so that they can pass the // generated ID on to the rest of the manipulation if ( $ isNewRecord ) { $ manipulation [ $ baseTable ] [ 'command' ] = 'update' ; } // Make sure none of our field assignment are arrays foreach ( $ manipulation as $ tableManipulation ) { if ( ! isset ( $ tableManipulation [ 'fields' ] ) ) { continue ; } foreach ( $ tableManipulation [ 'fields' ] as $ fieldName => $ fieldValue ) { if ( is_array ( $ fieldValue ) ) { $ dbObject = $ this -> dbObject ( $ fieldName ) ; // If the field allows non-scalar values we'll let it do dynamic assignments if ( $ dbObject && $ dbObject -> scalarValueOnly ( ) ) { throw new InvalidArgumentException ( 'DataObject::writeManipulation: parameterised field assignments are disallowed' ) ; } } } } // Perform the manipulation DB :: manipulate ( $ manipulation ) ; }
Generate and write the database manipulation for all changed fields

@param string $baseTable Base table
@param string $now Timestamp to use for the current time
@param bool $isNewRecord If this is a new record
@throws InvalidArgumentException
Generate and write the database manipulation for all changed fields