[PHP-NOTES] note 130417 added to mysqli.multi-query

[email protected] ("[email protected]") Mon, 14 Jul 2025 23:40:38 +0000 (UTC)
Newsgroups php.notes
Message-ID <[email protected]>
Follow-up about MySQL warnings with multi_query():

Although get_warnings() will not work with multi_query(), this doesn't totally prevent retrieval of the warnings.  The workaround is to splice ';SHOW WARNINGS;' between every query.  This is necessary because the warning count(s) won't be returned until after the queries are already sent and executed.

With that little workaround, every 2nd result set will be a warning list from the previous query.  This adds some overhead that isn't necessary in production, but can be vital for debugging any use of multi_query() during development.

Conclusion: If you need to see or log query warning strings then you can either avoid multi_query() or you can manually pull the warning list after every query.
----
Server IP: 45.112.84.4
Probable Submitter: 80.90.5.137 (proxied: 2601:803:c600:36c:644f:36a4:351d:8c41)
----
Manual Page -- https://php.net/manual/en/mysqli.multi-query.php
Edit        -- https://main.php.net/note/edit/130417
Del: integrated  -- https://main.php.net/note/delete/130417/integrated
Del: useless     -- https://main.php.net/note/delete/130417/useless
Del: bad code    -- https://main.php.net/note/delete/130417/bad+code
Del: spam        -- https://main.php.net/note/delete/130417/spam
Del: non-english -- https://main.php.net/note/delete/130417/non-english
Del: in docs     -- https://main.php.net/note/delete/130417/in+docs
Del: other reasons-- https://main.php.net/note/delete/130417
Reject      -- https://main.php.net/note/reject/130417
Search      -- https://main.php.net/manage/user-notes.php