id()
id() : string
A short lowercase identifier.
Returns
string —For example "truncate" or "shadow_swap".
How a table's contents get replaced.
There is more than one way and they are not equivalent. Truncating and refilling works on every driver and leaves the table empty for the duration; building a shadow table and renaming it into place leaves the original readable until the instant of the swap, and is only atomic on drivers that can rename two tables in one statement. A site in maintenance mode does not care about the difference; a site restoring one table while staying up cares a great deal.
Three rules bind every implementation:
isSupported() is checked before
anything is touched, and an unsupported strategy is refused rather than attempted.restore(\Drupal\Core\Database\Connection $database, string $table, list> $rows, list $columns) : int
Replaces a table's contents.
| \Drupal\Core\Database\Connection | $database | The connection. |
| string | $table | The table to replace. |
| list |
$rows | The rows to leave in it. An empty list empties the table, which is a legitimate restore target and is why this does not treat it as a mistake. |
| list |
$columns | The columns to write, in order. Given explicitly so a row carrying a column the table no longer has is refused rather than silently dropped. |
When the strategy is unsupported here, or the replacement failed. The table is left as it was in either case.
How many rows the table now holds.