Replace a PVC Toilet Flange
I fully agree with Marlin.
Hopefully, this toilet is over a crawlspace or basement where you can get to it. You can re-connect the new PVC pipe to the existing with either a PVC or a Fernco or a no-hub coupling.
PVC "glue" actually isn't a glue, but a type of "solvent" that chemically "welds" the PVC together. It isn't made to come apart. Ever. However, in extreme cases sometimes you can hacksaw blade the old flange in quarters and chisel it out, sand out the old pipe, and re-do it again.