Cannot execute multiple MariaDB queries using PHP(无法使用 PHP 执行多个 MariaDB 查询)
问题描述
我在 MariaDB 中执行 SQL 查询时遇到了一个小问题.所有 PHP 变量都不为空,我想同时执行两个查询.在 MySQL 中它可以工作,但在 MariaDB 服务器中我不能,因为我得到一个错误我有一个查询:
I have faced a slight problem with executing SQL query in MariaDB. All PHP variables are not empty and I would like to execute two queries at the same time. In MySQL it is working but in MariaDB server I cannot as I get an error I have a query:
UPDATE users SET name = $receivedName, email = $receivedEmail WHERE id = $id1; UPDATE posts SET id = $userid WHERE id = $receivedID
我得到的错误:
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'UPDATE posts SET id = 50 WHERE id = 56 /* /takechange.php */' at line 1
我知道执行分配给单个变量的两个查询并不是一个好主意,但目前我几乎无法更改任何代码.我想这不是如何在 MariaDB 中加入多个查询.你能告诉我如何编辑这个查询吗?
I know it is not a shiny idea to execute two queries which are assigned to single variable, but at the moment I can barely change any code. I guess this is not how to join multiple queries in MariaDB. Can you tell me how to edit this query?
提前致谢.
推荐答案
您需要使用 mysqli Multi Query 或执行您的语句单独.
You need to use mysqli Multi Query or execute your statements separately.
如您所知,您有多个正在传递的语句.
You have multiple statements being passed as you know.
多查询
执行一个或多个由 a 连接的查询分号.
Executes one or multiple queries which are concatenated by a semicolon.
这篇关于无法使用 PHP 执行多个 MariaDB 查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:无法使用 PHP 执行多个 MariaDB 查询
- SoapClient 设置自定义 HTTP Header 2021-01-01
- Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01
- 如何定位 php.ini 文件 (xampp) 2022-01-01
- Laravel 仓库 2022-01-01
- PHP Count 布尔数组中真值的数量 2021-01-01
- 带有通配符的 Laravel 验证器 2021-01-01
- 正确分离 PHP 中的逻辑/样式 2021-01-01
- 没有作曲家的 PSR4 自动加载 2022-01-01
- 从 PHP 中的输入表单获取日期 2022-01-01
- Mod使用GET变量将子域重写为PHP 2021-01-01