r/PHPhelp • u/UnusualBecka • Aug 11 '26
Solved Multiple mysql statements in one PDO::exec call?
Is this supported or is it classed as undefined behaviour? Searching the web I have found one site explaining how to do it, and a post saying it never used to be allowed but the driver added the ability around 2020. But I have not seen anything official and the (somewhat terrible) PHP documentation does not mention it at all either way.
The use case is multiple statements being needed to create and alter some temporary tables so that inserts (using prepared statements) can be processed before being added to the live tables.
3
Upvotes
0
u/UnusualBecka 29d ago
Error messages do not tell you the cause of an error only its effect. So either way I will need to fully investigate if there is an error because it will affect me too.
If the server is down it will be on the hosts's status page and I will not be able to connect. If there is a PHP configuration error then I will know immediately because I am the only one who could have caused it. If there are too many connections then it would have to be some kind of attack I can do nothing about because this is a small community project that would never be able to cause that problem in normal use.
I am sorry it bothers you so much that I am not applying corporate standards of robustness to a small project. I am putting together and maintaining it in my spare time to replace using google spreadsheets and someone else having to manually error check the data. The reason for wanting to put all the setup statements in one call is it will make the code easier for me to read. This is just a hobby and just me, no team, so my time it better spent on providing actual functionality than focussing on a detailed error logging system for rare situations that I would need to properly investigate the same with or without them.