private function updateObject(Model $object)
    {
        $schema = $this->reposSchema;
        $changes = $object->getModelChanges();
        $schemaColumns = $schema->getColumns();

        $params = [];
        $columns = [];

        $sql = "UPDATE `{$schema->schemaName}`";

        foreach ($changes as $columnName => $value) {

            if ($columnName == $schema->uniqueIdentifierColumnName) {
                continue;
            }

            $changeData = $changes;

            if (isset($schemaColumns[$columnName])) {
                $storageColumns = $schemaColumns[$columnName]->getStorageColumns();

                $transforms = $this->columnTransforms[$columnName];

                if ($transforms[1] !== null) {
                    $closure = $transforms[1];

                    $transformedData = $closure($changes);

                    if (is_array($transformedData)) {
                        $changeData = $transformedData;
                    } else {
                        $changeData[$columnName] = $transformedData;
                    }
                }

                foreach ($storageColumns as $storageColumnName => $storageColumn) {
                    $value = (isset($changeData[$storageColumnName])) ? $changeData[$storageColumnName] : null;

                    $columns[] = "`" . $storageColumnName . "` = :" . $storageColumnName;

                    $params[$storageColumnName] = $value;
                }
            }
        }

        if (sizeof($columns) <= 0) {
            return;
        }

        $sql .= " SET " . implode(", ", $columns);
        $sql .= " WHERE `{$schema->uniqueIdentifierColumnName}` = :{$schema->uniqueIdentifierColumnName}";

        $params[$schema->uniqueIdentifierColumnName] = $object->UniqueIdentifier;

        $statement = $this->executeStatement($sql, $params);

        return $statement->rowCount();
    }
private function updateObject(Model $object)
    {
        $schema = $this->reposSchema;
        $changes = $object->getModelChanges();
        $schemaColumns = $schema->getColumns();

        $params = [];
        $columns = [];

        $sql = "UPDATE `{$schema->schemaName}`";

        foreach ($changes as $columnName => $value) {

            if ($columnName == $schema->uniqueIdentifierColumnName) {
                continue;
            }

            $changeData = $changes;

            if (isset($schemaColumns[$columnName])) {
                $storageColumns = $schemaColumns[$columnName]->getStorageColumns();

                $transforms = $this->columnTransforms[$columnName];

                if ($transforms[1] !== null) {
                    $closure = $transforms[1];

                    $transformedData = $closure($changes);

                    if (is_array($transformedData)) {
                        $changeData = $transformedData;
                    } else {
                        $changeData[$columnName] = $transformedData;
                    }
                }

                foreach ($storageColumns as $storageColumnName => $storageColumn) {
                    $value = (isset($changeData[$storageColumnName])) ? $changeData[$storageColumnName] : null;

                    $columns[] = "`" . $storageColumnName . "` = :" . $storageColumnName;

                    $params[$storageColumnName] = $value;
                }
            }
        }

        if (sizeof($columns) <= 0) {
            return;
        }

        $sql .= " SET " . implode(", ", $columns);
        $sql .= " WHERE `{$schema->uniqueIdentifierColumnName}` = :{$schema->uniqueIdentifierColumnName}";

        $params[$schema->uniqueIdentifierColumnName] = $object->UniqueIdentifier;

        $statement = $this->executeStatement($sql, $params);

        return $statement->rowCount();
    }
private function updateObject ( Model $ object ) { $ schema = $ this -> reposSchema ; $ changes = $ object -> getModelChanges ( ) ; $ schemaColumns = $ schema -> getColumns ( ) ; $ params = [ ] ; $ columns = [ ] ; $ sql = "UPDATE `{$schema->schemaName}`" ; foreach ( $ changes as $ columnName => $ value ) { if ( $ columnName == $ schema -> uniqueIdentifierColumnName ) { continue ; } $ changeData = $ changes ; if ( isset ( $ schemaColumns [ $ columnName ] ) ) { $ storageColumns = $ schemaColumns [ $ columnName ] -> getStorageColumns ( ) ; $ transforms = $ this -> columnTransforms [ $ columnName ] ; if ( $ transforms [ 1 ] !== null ) { $ closure = $ transforms [ 1 ] ; $ transformedData = $ closure ( $ changes ) ; if ( is_array ( $ transformedData ) ) { $ changeData = $ transformedData ; } else { $ changeData [ $ columnName ] = $ transformedData ; } } foreach ( $ storageColumns as $ storageColumnName => $ storageColumn ) { $ value = ( isset ( $ changeData [ $ storageColumnName ] ) ) ? $ changeData [ $ storageColumnName ] : null ; $ columns [ ] = "`" . $ storageColumnName . "` = :" . $ storageColumnName ; $ params [ $ storageColumnName ] = $ value ; } } } if ( sizeof ( $ columns ) <= 0 ) { return ; } $ sql .= " SET " . implode ( ", " , $ columns ) ; $ sql .= " WHERE `{$schema->uniqueIdentifierColumnName}` = :{$schema->uniqueIdentifierColumnName}" ; $ params [ $ schema -> uniqueIdentifierColumnName ] = $ object -> UniqueIdentifier ; $ statement = $ this -> executeStatement ( $ sql , $ params ) ; return $ statement -> rowCount ( ) ; }
Crafts and executes an SQL statement to update the object in MySQL

@param \Rhubarb\Stem\Models\Model $object
@return int|void
Crafts and executes an SQL statement to update the object in MySQL