MySQL 和 PHP 同步性健全性检查

发布于 2024-09-27 18:53:06 字数 375 浏览 0 评论 0原文

我正在排除一个错误,并试图排除所有可能的解释,解释为什么我会目睹我的行为。我正在 PHP 中执行许多 MySQL 查询(通过 CodeIgniter 的 Active Record 类)我所看到的行为的一种解释是查询没有同步执行,即 PHP 在发出下一个查询之前不会等待查询完成。

我总是在这样的假设下进行编码:如果我通过 PHP insert 某些内容到 MySQL 表中,然后我的下一行代码执行 select,我插入的结果将在下一个声明中提供。这种情况有例外吗?

I'm troubleshooting a bug and trying to rule out all possible explanations for why I'm witnessing the behavior that I am. I'm executing a number of MySQL queries in PHP (via CodeIgniter's Active Record class) and one explanation for the behavior that I'm seeing is that the queries aren't being executed synchronously, i.e. that PHP isn't waiting for the query to complete before issuing the next one.

I've always coded under the assumptions that if I insert something into a MySQL table via PHP, and then my next line of code executes a select, the results of my insertion will be available in the next statement. Are there any exceptions to this being the case?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

誰認得朕 2024-10-04 18:53:07

如果您在相同服务器上选择它,并且使用相同会话/连接,并且您没有使用INSERT DELAYED,那么它应该存在确实如此,但是负载平衡的 MySQL 服务器/实现/缓存可能会将 SELECT 转移到其他服务器或数据位置......

If you select it on the same server, and are using the same session/connection, and you haven't used INSERT DELAYED it should exist indeed, but loadbalanced MySQL servers / implementations / caching may divert SELECT's to other servers or data locations....

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文