My PHP code allows users to execute arbitrary SQL code in a read-only user. It also needs access to a write capable user. My code executes commands in the "write capable user" and then using a separate connection queries the db using the "read-only user". It then queries using the "write capable user" again and exits the script.
It leaves the write capable user's connection open while it does the read-only user's queries. As far as I am aware this is the best way to do it but my college is concerned the is somehow MySQL bad practice and want to close the write capable user's connection and reopen it later (presumably because it doubles the number of concurrent connections to the MySQL.) What is the best way to do this?
whats more efficient and why: one db connection per page or one db connection per function? says that "Typically database connections are expensive to create."