1

The documentation of mysqli_multi_query and mysqli_query doesn't say if calling mysqli_multi_query is the same as calling mysqli_query multiple times.

Does anyone know the answer?

Dharman
  • 30,962
  • 25
  • 85
  • 135
guigoz
  • 674
  • 4
  • 21

1 Answers1

2

No. mysqli_multi_query is asynchronous, it will send all queries to a database server but return only the first result immediately. Therefore to check the result of all other queries you will need some additional code. Whereas to run a set of mysql_query() you dont't need any additional code, but just use the every query's result right away.

That said, both functions have a very limited use. The only application for mysqli_multi_query is to run some pre-written sql dumps. mysql_query() has a very limited use too, as there are not so much queries that do not accept variable data. And for such queries you must use mysqli_prepare() instead.

Your Common Sense
  • 156,878
  • 40
  • 214
  • 345
  • mysqli_query is also asynchronous when called with `MYSQLI_ASYNC`. The first result returned by mysqli_poll+mysqli_reap_async_query is the first that is ready. The control is also given for each query run asynchronously since the thread_id is available for each one. Would this make mysql_query better than mysqli_multi_query? – guigoz Jul 24 '19 at 16:01
  • I don't understand your criteria for comparing these functions so I can't tell. All I can tell mysqli_multi_query will wait for the first query result but async mysqli_query will not. I don't get the idea of all that comparison though – Your Common Sense Jul 24 '19 at 16:09