mysql连接如何工作

mysqli_insert_id() is specific to the database connection -- it returns the ID of the row that this script invocation inserted most recently, not any other MySQL client. So there's no conflict if multiple applications are inserting into the database at the same time.

I am confused in 2 things first one is

specific to the database connection

and second thing

MySQL client

Please is there anyone who can explian that how mysql connections work for different clients or how these clients behave in any Application. I am sorry if it is a riddiculous question but i am confused that why it is not reflected by the data entry at the same time.

specific to the database connection

Suppose I run a PHP script that inserts a row, and then calls mysqli_insert_id(), and it tells me it generated value 1234.

Next, you also run a separate PHP script that inserts a row to the same table. We assume it generated value 1235.

Then my PHP script, still running in the same request as before, calls mysqli_insert_id() again. Does it report 1235? No -- it still reports 1234, because it will tell me only the most recent id generated during my session.

If my PHP request finishes, and then I make another PHP request, and it connects to MySQL, this counts as a new connection. Mysqli_insert_id() reports nothing by default, unless I do a new insert.

MySQL client

In this context, a mysql client is for example the PHP script that makes a connection to MySQL during one request.

A MySQL client can also be the command-line mysql tool, or a GUI interface like MySQL Workbench, or another application written in PHP or another language. The term "MySQL client" is meant to include all of these. Each client makes a connection to the MySQL database server, and each connection has its own idea of what the last insert id was.