You can update DB records, in example:
$admin = $DB->get_record('user',['email'=>'oldadminemail@mail.com']);
$admin->email = 'newadminemail@mail.com';
$DB->update_record('user',$admin);
More information can be found here: https://docs.moodle.org/dev/Data_manipulation_API
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…