Can DataList be used as a base for a MySQL UPDATE query?

Silverstripe Version: 4.*


Hi, I would like to do some batch data assigning using DataLists. The idea is to use the handy filtering methods offered by the ORM to select a specific group of records in the database and then assign a value to a specific column. The value will be the same for all records matched by the defined filters.

Here is some kind of pseudo code that shows what this could look like:

$pages = Page::get()->filter('Title', 'foo')->UPDATE(['Title' => 'New Title']);

This would immediately execute the following MySQL query:

WHERE `Title` = "foo"
SET `Title` = "New Title"

I know that the DataList class does not directly provide a method for this, so my question is that is there some reliable way to transform the DataList’s underlying DataQuery object to an SQLUpdate object?