无法从自动增量返回id

编程入门 行业动态 更新时间:2024-10-25 02:22:12
本文介绍了无法从自动增量返回id的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

请有人帮忙。我搜索了大量的论坛和网站,但似乎没有人给我答案。 我已经将信息发布到我的数据库,我希望返回id使用mysqli_insert_id()函数。我把它发布到php。请有人帮忙,因为没有返回整数而有点生气。

Could someone please help. I''ve searched alot of forums and website but none seem to give me the answer. I''ve posted info to my database and i''m looking to return the id using the mysqli_insert_id() function. I''m posting it to php. Please someone help, going a bit mad as no integer is returned.

展开 | 选择 | Wrap | 行号 推荐答案

mysqli_insert_id()函数返回由具有AUTO_INCREMENT属性的列的表上的查询生成的ID。如果最后一个查询不是INSERT或UPDATE语句,或者如果修改后的表没有具有AUTO_INCREMENT属性的列,则此函数将返回零。 注意:使用LAST_INSERT_ID()函数执行INSERT或UPDATE语句也会修改mysqli_insert_id()函数返回的值。 返回值 上一个查询更新的AUTO_INCREMENT字段的值。如果连接上没有先前查询或查询未更新AUTO_INCREMENT值,则返回零。 注意:如果数字大于最大int值,mysqli_insert_id()将返回一个字符串。 The mysqli_insert_id() function returns the ID generated by a query on a table with a column having the AUTO_INCREMENT attribute. If the last query wasn''t an INSERT or UPDATE statement or if the modified table does not have a column with the AUTO_INCREMENT attribute, this function will return zero. Note: Performing an INSERT or UPDATE statement using the LAST_INSERT_ID() function will also modify the value returned by the mysqli_insert_id() function. Return Values The value of the AUTO_INCREMENT field that was updated by the previous query. Returns zero if there was no previous query on the connection or if the query did not update an AUTO_INCREMENT value. Note: If the number is greater than maximal int value, mysqli_insert_id() will return a string.

mysqli语句是mysqli_stmt_insert_id 。但是,文档中还没有进一步的描述,但它应该像[php] mysqli_stmt_insert_id( The mysqli statement for this is mysqli_stmt_insert_id. However, there is no further description (yet) in the documenation, but it should be something like[php]mysqli_stmt_insert_id(

result); [/ php]如果你不确定你能不能总是使用MySqli的LAST_INSERT_ID()函数,你的代码就像:[php] if( result);[/php]If you are not sure you can always use the LAST_INSERT_ID() function of MySqli and your code would then be something like:[php]if(

更多推荐

无法从自动增量返回id

本文发布于:2023-10-15 02:36:08,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1493003.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:增量   id

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!