Home > Backend Development > PHP Tutorial > PHP取得当前插入数据库中记录的id值_PHP

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

WBOY
Release: 2016-06-01 12:29:36
Original
897 people have browsed it

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

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

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

Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template