脚本宝典收集整理的这篇文章主要介绍了php – mysqli最后插入的id,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
$image = $MysqLi->insert_id;//this should come From table2 $stmt = $MysqLi->PRepare(" insert into table1 (username,firstname,lastname,image) select ?,?,image from table2 t2 where username = ? and t2.id = ? "); $stmt->bind_param('sssss',$username,$fname,$lname,$image); $stmt->execute();
$MysqLi = new MysqLi("localhost","my_user","my_password","world"); /* check connection */ if (MysqLi_connect_errno()) { printf("Connect Failed: %s\n",MysqLi_connect_error()); exIT(); } $MysqLi->query("CREATE TABLE myCity LIKE City"); $query = "INSERT INTO myCity VALUES (NULL,'Stuttgart','DEU',617000)"; $MysqLi->query($query); printf ("New Record has id %d.\n",$MysqLi->insert_id); /* drop table */ $MysqLi->query("DROP TABLE myCity"); /* close connection */ $MysqLi->close();
产量
参考
> PHP mysqli_insert_id: http://www.php.net/manual/en/mysqli.insert-id.php
以上是脚本宝典为你收集整理的php – mysqli最后插入的id全部内容,希望文章能够帮你解决php – mysqli最后插入的id所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。