Skip to content

dynamically add new Entry to row #256

Answered by norberttech
azngeek asked this question in Q&A
Discussion options

You must be logged in to vote

Oh I see, so here are a few examples of how you can achieve it.
You were almost good, but you need to remember that Rows is immutable, which means that while iterating using foreach even if you change something at a single Row it wont affect Rows.
To adjust Rows you should use Rows::map(static fn (Row $row) : Row => $row) that will return a new instance of Rows that would include your changes at each Row you made through the anonymous function.

<?php

use Flow\ETL\DSL\Entry;
use Flow\ETL\DSL\From;
use Flow\ETL\DSL\To;
use Flow\ETL\DSL\Transform;
use Flow\ETL\Flow;
use Flow\ETL\Memory\ArrayMemory;
use Flow\ETL\Row;
use Flow\ETL\Rows;
use Flow\ETL\Transformer;

require __DIR__ . '/../vendor…

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by norberttech
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #248 on June 09, 2022 21:45.