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

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

WBOY
WBOYOriginal
2016-06-01 12:31:14714browse

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

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

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

Statement:
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