In Typo3 extbase, what's the most efficient way to update maybe 300 records, without calling 300 separate occasions of open-connection -> do update -> close connection?
The Basic CRUD page of the manual, Docs » API Overview » Database (doctrine-dbal) » Basic CRUD (https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/ApiOverview/Database/BasicCrud/Index.html#update-multiple-rows) suggests that you should update multiple rows using
GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('tt_content')
->update(
'tt_content',
[ 'bodytext' => 'bernd' ], // set
[ 'bodytext' => 'klaus' ] // where
);
But this code implies updating only a single row. How do I do something like this below...?
GeneralUtility::makeInstance(ConnectionPool::class)
->getConnectionForTable('tt_content')
->update(
'table_name',
[ 'field' => 'newValue', 'uid'=>'1' ], // set field:value, where field:value
[ 'field' => 'newValue', 'uid'=>'7' ], // set field:value, where field:value
[ 'field' => 'newValue', 'uid'=>'5' ], // set field:value, where field:value
[ 'field' => 'newValue', 'uid'=>'9' ], // set field:value, where field:value
etc.
);
instead of
foreach($arrUpdate $key => $row) {
...get a new db connection and do a single update...
};
Many thanks in advance for any suggestions anyone has.