In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
Today, I will talk to you about how to use the mysqli_insert_id MySQLi function in PHP. Many people may not know much about it. In order to make you understand better, the editor has summarized the following for you. I hope you can get something according to this article.
Mysqli_insert_id-returns the self-incrementing ID generated by the last insert statement
Syntax: mysqli_insert_id (mysqli $link)
The mysqli_insert_id () function returns the value of the column set to AUTO_INCREMENT in the table operated by the last SQL statement (usually the INSERT statement). If the last SQL statement is not an INSERT or UPDATE statement, or if there is no column set to AUTO_INCREMENT in the table being operated on, the return value is 0.
Note: if the database function LAST_INSERT_ID () is used in the INSERT or UPDATE statements being executed. It is possible to affect the return value of the mysqli_insert_id () function.
Parameters.
The required description of the parameter link is identified by the link returned by mysqli_connect () or mysqli_init (). Return value
The value of the column set to the AUTO_INCREMENT attribute in the table operated by the last SQL (INSERT or UPDATE). Returns 0 if the SQL statement has not been executed on the specified connection, or if the table operated on by the last SQL statement does not have a column set to AUTO_INCREMENT.
Note: if the return value exceeds the maximum integer value allowed by php, the mysqli_insert_id () function returns this value as a string. $link = mysqli_connect ("localhost", "my_user", "my_password", "world"); / * check connection * / if (mysqli_connect_errno ()) {printf ("Connect failed:% s\ n", mysqli_connect_error ()); exit ();} mysqli_query ($link, "CREATE TABLE myCity LIKE City"); $query = "INSERT INTO myCity VALUES (NULL, 'Stuttgart',' DEU', 'Stuttgart', 617000)" Mysqli_query ($link, $query); printf ("New Record has id% d.\ n", mysqli_insert_id ($link)); / * delete table * / mysqli_query ($link, "DROP TABLE myCity"); / * close connection * / mysqli_close ($link); after reading the above, do you have any further understanding of how to use the mysqli_insert_id MySQLi function in PHP? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.