Each and every SQL query I issue to my MySQL
server creates a new (increments) CONNECTION_ID()
. This happens both on my local as well as on my shared remote server.
Is this the reason behind LAST_INSERT_ID()
and ROW_COUNT()
resulting in 0
? How to address this issue?
Originally in MySQL: LAST_INSERT_ID() returns 0
The MySQL CONNECTION_ID() function is used for return the connection ID for a current connection in MySQL. The connection ID used to establish a connection to a database is unique for every connection among the connected clients. The CONNECTION_ID() function does not require any parameters or arguments.
In MySQL the ROW_COUNT() function is used to return the number of rows affected by the previous SQL statement. If the previous statement was not one that could potentially change data rows or you can say, it wasn't an INSERT, UPDATE, DELETE or other such statement this function will return -1.
mysql> SELECT CURRENT_USER(); Here is the output that displays the name of the current user. In the above, % tells us about localhost. mysql> SELECT CONNECTION_ID();
Authentication ID Each row in the mysql. user table is identified by a user and host tuple. This tuple is the authorization ID. A client can authenticate with an authorization ID and a password. The ID is then referred to as a user or user name.
By default, PersistentConnections
are disabled in phpMyAdmin.
Is this the reason behind
LAST_INSERT_ID()
andROW_COUNT()
resulting in0
?
Yes.
How to address this issue?
Enable persistent connections:
$cfg['PersistentConnections'] = TRUE;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With