使用$ mysqli-> insert_id分配主题以发布在论坛脚本中是否安全? [英] It is safe to use $mysqli->insert_id for assign topic to post in a forum script?

查看:60
本文介绍了使用$ mysqli-> insert_id分配主题以发布在论坛脚本中是否安全?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个论坛脚本,该脚本为每个新主题创建一个容器",并将与该主题链接的每个帖子分配给该主题.

I've a forum script that makes for every new topic a "container" and assign to it each post linked to the topic.

因此,当我打开一个新主题时,我的脚本会在forum_topics中创建一个新行,并在forum_posts中创建一个新行.

So, when I open a new topic my script makes a new row in forum_topics and a new row in forum_posts.

forum_posts中,将主题容器的id放入parent列.

要知道谁是我正在创建的帖子的容器,我使用:

For know who is the container of the post I'm creating I use:

$mysqli->insert_id

我想知道它是否安全,我认为对于同时打开一个新主题的两个用户...这是一个合理的问题吗?

I'd like to know if it is safe, I think to two users who open a new topic at the same time... It is a plausible problem?

推荐答案

是的,它很安全.
每个PHP进程使用单独的连接,并且此变量包含此连接中插入的ID

Yes it is safe.
Each PHP process uses separate connection and this variable contains inserted id from this very connection

这篇关于使用$ mysqli-> insert_id分配主题以发布在论坛脚本中是否安全?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆