Perhaps this is not best practice, but i was curious about the how and why.
When accessing a MySQL DB, i often use a technique in which I build a query string then use mysqli_query() to access the DB. In some cases I have multiple, unrelated or partially related queries. Mu usual technique for this would be to run a loop or call the function that contains mysqli_query() multiple times. No big, but it strikes me that I am making server calls for each individual query, even tho I know all the queries beforehand.
I guess what makes me ask this question is that I was experimenting and noticed that in myPHPadmin i can run multiple queries in one swoop, as long as each query string ends with “;” My question is, why doesnt this work with mysqli_query()?
For example, when I send this string:" SELECT * FROM myTable
WHERE thatCell
=8; UPDATE myTable
SET thatCell
=thatCell
+1 WHERE thatCell
=6" It returns FALSE and nothing is either select or done. (incidentally I find that this all or nothing behavior quite appealing… if it ever was ALL)
however if I send TWO queries:
- “SELECT * FROM
myTable
WHEREthatCell
=8”
2)" UPDATEmyTable
SETthatCell
=thatCell
+1 WHEREthatCell
=6"
it works perfectly!!! So I am assuming that there was nothing wrong with the syntax of my queries individually but that I am not joining them together in a way that PHP’s mysqli_query() function can use? Can’t mysqli_query() handle “;” delimetered functions at all?
advice from the forum experts is welcomed as always