Php+mssql get last Insert ID value problem (online etc ~)
I remember MySQL has a mysql_insert_id () function to get the last inserted ID, such as $newid = mysql_insert_id (); What about the MSSQL database? Is there such a function? How do I output
Call MySQL in PHP, built-in last_insert_id () This function may not be used by anyone, the most used or mysql_insert_id ()
In fact, these two are different, last_insert_id () can return the ID of the bigint value. Instead, MYSQL_INSERT_ID returns
This problem has been encountered by the cliff before, too long did not write do not remember (seems to be the CI frame directly related functions), and then met again, rolled to check again, here is not the case is PDO, but with the outdated
many times we want to know when inserting data to MySQL The ID of the channel just inserted the data this is useful for us. Below I say three kinds of common methods and analyze their pros and cons one with the following statement: mysql_query ("
Three kinds of return to MySQL tutorial insert a record to return the record ID method
Method One
ID Int (one) not null PRI key auto_increment,name varchar (a), backup varchar (50)Now, when you want to insert a record, return his ID value (insert
mysql_query ("SELECT Max (ID) from T1", $link);
Copy CodeUsing this method gives the highest ID value, which is the last value, but when a multilink thread, this maximum ID is not necessarily the self-increment ID value of the inserted data,
Provides various official and user-released code examples. For code reference, you are welcome to learn how to fix the data insertion BUG in TP + ORACLE and obtain the auto-increment Id. The getLastInsID method is supported.
During Api operations
Five vulnerable PHP database errors. Five vulnerable PHP database errors-including database pattern design, database access and database use business logic code-and their solutions. If there is only one way to use five vulnerable PHP database errors-
PHP can obtain the ID of a new MySql record. 1. use the statement: Copy the code as follows: mysql_query (selectmax (id) fromt1, $ link); use this method to obtain the largest value of id, which is indeed the last value, however, when multiple
"PHP" MySQL gets the primary key for inserting data (self-increment id), MySQL primary key
To prevent primary key collisions, the self-increment (auto_increment) field is often used when designing db. So before inserting the data, we often don't
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.