Home > php教程 > php手册 > 取得当前插入数据库中记录的id值

取得当前插入数据库中记录的id值

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-21 08:59:48
Original
975 people have browsed it

在PHP中,经常需要把插入数据库中的id值取出来,而正好有这么一个函数:

//执行插入数据库的语句
//……
$getID=mysql_insert_id();//$getID即为最后一条记录的ID
 ?>

PHP 函数 mysql_insert_id() 是返回在最后一次执行了 INSERT 查询后,由 AUTO_INCREMENT 定义的字段的值。



Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php - pdo fails to insert data into database?
From 1970-01-01 08:00:00
0
0
0
Pass array to SQL insert query using PHP
From 1970-01-01 08:00:00
0
0
0
mongodb - How to batch insert data in mongoose?
From 1970-01-01 08:00:00
0
0
0
python - mysql insert error in multithreading
From 1970-01-01 08:00:00
0
0
0
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template