This time you need transaction po because you are doing two queries Insert and Update. ($db->begin() and $db->commit())
Don't forget to rollback po if the queries failed po. :bow: