query(' SELECT id_asset, variable, value FROM assets_meta WHERE variable LIKE {string:thumbs}', ['thumbs' => 'thumb_%']); while ($row = $db->fetch_assoc($res)) { if (!preg_match('~^thumb_(?\d+)x(?\d+)(?:_(?c[best]?))?$~', $row['variable'], $match)) continue; echo 'Migrating ... ', $row['value'], '(#', $row['id_asset'], ")\r"; $db->insert('replace', 'assets_thumbs', [ 'id_asset' => 'int', 'width' => 'int', 'height' => 'int', 'mode' => 'string-3', 'filename' => 'string-255', ], [ 'id_asset' => $row['id_asset'], 'width' => $match['width'], 'height' => $match['height'], 'mode' => $match['mode'] ?? '', 'filename' => $row['value'], ]); } echo "\nDone\n";