Laying in bed watching TV but something along the lines of
$result = $db->query('
SELECT version, when, opcodes
FROM msg_history
WHERE id_msg = {int:id_msg}
AND version > {int:version}
ORDER BY version',
['id_msg' => 62, 'version' => 3]
);
// Didn't feel like writing a sort function here, but it would be sorted by version
// Put the result into an array = $history
$render = = new cogpowered\FineDiff\Render\Text;
$msg = $original_msg;
foreach ($history as $post)
{
$msg = $render->process($msg, $post['opcodes']);
}
return $msg;