src/ORM/DataObject.php
protected function prepareManipulationTable($baseTable, $now, $isNewRecord, &$manipulation, $class)
    {
        $schema = $this->getSchema();
        $table = $schema->tableName($class);
        $manipulation[$table] = array();

        $changed = $this->getChangedFields();

        // Extract records for this table
        foreach ($this->record as $fieldName => $fieldValue) {
            // we're not attempting to reset the BaseTable->ID
            // Ignore unchanged fields or attempts to reset the BaseTable->ID
            if (empty($changed[$fieldName]) || ($table === $baseTable && $fieldName === 'ID')) {
                continue;
            }

            // Ensure this field pertains to this table
            $specification = $schema->fieldSpec(
                $class,
                $fieldName,
                DataObjectSchema::DB_ONLY | DataObjectSchema::UNINHERITED
            );
            if (!$specification) {
                continue;
            }

            // if database column doesn't correlate to a DBField instance...
            $fieldObj = $this->dbObject($fieldName);
            if (!$fieldObj) {
                $fieldObj = DBField::create_field('Varchar', $fieldValue, $fieldName);
            }

            // Write to manipulation
            $fieldObj->writeToManipulation($manipulation[$table]);
        }

        // Ensure update of Created and LastEdited columns
        if ($baseTable === $table) {
            $manipulation[$table]['fields']['LastEdited'] = $now;
            if ($isNewRecord) {
                $manipulation[$table]['fields']['Created'] = empty($this->record['Created'])
                    ? $now
                    : $this->record['Created'];
                $manipulation[$table]['fields']['ClassName'] = static::class;
            }
        }

        // Inserts done one the base table are performed in another step, so the manipulation should instead
        // attempt an update, as though it were a normal update.
        $manipulation[$table]['command'] = $isNewRecord ? 'insert' : 'update';
        $manipulation[$table]['class'] = $class;
        if ($this->isInDB()) {
            $manipulation[$table]['id'] = $this->record['ID'];
        }
    }
protected function prepareManipulationTable($baseTable, $now, $isNewRecord, &$manipulation, $class)
    {
        $schema = $this->getSchema();
        $table = $schema->tableName($class);
        $manipulation[$table] = array();

        $changed = $this->getChangedFields();

        // Extract records for this table
        foreach ($this->record as $fieldName => $fieldValue) {
            // we're not attempting to reset the BaseTable->ID
            // Ignore unchanged fields or attempts to reset the BaseTable->ID
            if (empty($changed[$fieldName]) || ($table === $baseTable && $fieldName === 'ID')) {
                continue;
            }

            // Ensure this field pertains to this table
            $specification = $schema->fieldSpec(
                $class,
                $fieldName,
                DataObjectSchema::DB_ONLY | DataObjectSchema::UNINHERITED
            );
            if (!$specification) {
                continue;
            }

            // if database column doesn't correlate to a DBField instance...
            $fieldObj = $this->dbObject($fieldName);
            if (!$fieldObj) {
                $fieldObj = DBField::create_field('Varchar', $fieldValue, $fieldName);
            }

            // Write to manipulation
            $fieldObj->writeToManipulation($manipulation[$table]);
        }

        // Ensure update of Created and LastEdited columns
        if ($baseTable === $table) {
            $manipulation[$table]['fields']['LastEdited'] = $now;
            if ($isNewRecord) {
                $manipulation[$table]['fields']['Created'] = empty($this->record['Created'])
                    ? $now
                    : $this->record['Created'];
                $manipulation[$table]['fields']['ClassName'] = static::class;
            }
        }

        // Inserts done one the base table are performed in another step, so the manipulation should instead
        // attempt an update, as though it were a normal update.
        $manipulation[$table]['command'] = $isNewRecord ? 'insert' : 'update';
        $manipulation[$table]['class'] = $class;
        if ($this->isInDB()) {
            $manipulation[$table]['id'] = $this->record['ID'];
        }
    }
protected function prepareManipulationTable ( $ baseTable , $ now , $ isNewRecord , & $ manipulation , $ class ) { $ schema = $ this -> getSchema ( ) ; $ table = $ schema -> tableName ( $ class ) ; $ manipulation [ $ table ] = array ( ) ; $ changed = $ this -> getChangedFields ( ) ; // Extract records for this table foreach ( $ this -> record as $ fieldName => $ fieldValue ) { // we're not attempting to reset the BaseTable->ID // Ignore unchanged fields or attempts to reset the BaseTable->ID if ( empty ( $ changed [ $ fieldName ] ) || ( $ table === $ baseTable && $ fieldName === 'ID' ) ) { continue ; } // Ensure this field pertains to this table $ specification = $ schema -> fieldSpec ( $ class , $ fieldName , DataObjectSchema :: DB_ONLY | DataObjectSchema :: UNINHERITED ) ; if ( ! $ specification ) { continue ; } // if database column doesn't correlate to a DBField instance... $ fieldObj = $ this -> dbObject ( $ fieldName ) ; if ( ! $ fieldObj ) { $ fieldObj = DBField :: create_field ( 'Varchar' , $ fieldValue , $ fieldName ) ; } // Write to manipulation $ fieldObj -> writeToManipulation ( $ manipulation [ $ table ] ) ; } // Ensure update of Created and LastEdited columns if ( $ baseTable === $ table ) { $ manipulation [ $ table ] [ 'fields' ] [ 'LastEdited' ] = $ now ; if ( $ isNewRecord ) { $ manipulation [ $ table ] [ 'fields' ] [ 'Created' ] = empty ( $ this -> record [ 'Created' ] ) ? $ now : $ this -> record [ 'Created' ] ; $ manipulation [ $ table ] [ 'fields' ] [ 'ClassName' ] = static :: class ; } } // Inserts done one the base table are performed in another step, so the manipulation should instead // attempt an update, as though it were a normal update. $ manipulation [ $ table ] [ 'command' ] = $ isNewRecord ? 'insert' : 'update' ; $ manipulation [ $ table ] [ 'class' ] = $ class ; if ( $ this -> isInDB ( ) ) { $ manipulation [ $ table ] [ 'id' ] = $ this -> record [ 'ID' ] ; } }
Writes a subset of changes for a specific table to the given manipulation

@param string $baseTable Base table
@param string $now Timestamp to use for the current time
@param bool $isNewRecord Whether this should be treated as a new record write
@param array $manipulation Manipulation to write to
@param string $class Class of table to manipulate
Writes a subset of changes for a specific table to the given manipulation