DEV Community

Discussion on: Should I save the code submitted by the users before running and testing it?

simplegeek profile image

Typically you want to avoid checking a database to determine when to perform an action, in your case, test the code the user submits. This is because polling a database like this, particularly every second, is very resource intensive. So, you might want to try just running the code when the user enters it, and then save it, thereby avoiding the whole "check the database" step, and just retrieve the code when the user needs it again (this is called event-driven programming, if you're curious). I'm afraid I can't offer any specifics on how to test the code using PHP (I'm more of a Java guy), but these are just some thoughts to keep in mind as you design your project.

Hope this helps!

alex002i profile image
Alex Author

It helps, thank you!