所有查询都是独立工作的,但实际上很难将所有内容组合到一个结果中,因此我可以将其与mysql_fetch_array一起使用。
我试图创建视图以及临时表,但是每次它说表不存在或返回一个空的获取数组循环时……都有逻辑但语法混乱,我认为这是我第一次处理多个查询,我需要将所有查询合并在一起。期待获得支持。非常感谢。
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。
多亏了php.net,我提出了一个解决方案:您必须使用它(mysqli_multi_query($link, $query))来运行多个串联的查询。
/* create sql connection*/ $link = mysqli_connect("server", "user", "password", "database");
$query = "SQL STATEMENTS;"; /* first query : Notice the 2 semicolons at the end ! / $query .= "SQL STATEMENTS;"; / Notice the dot before = and the 2 semicolons at the end ! / $query .= "SQL STATEMENTS;"; / Notice the dot before = and the 2 semicolons at the end ! / $query .= "SQL STATEMENTS"; / last query : Notice the dot before = at the end ! */
/* Execute queries */
if (mysqli_multi_query($link, $query)) { do { /* store first result set */ if ($result = mysqli_store_result($link)) { while ($row = mysqli_fetch_array($result))
/* print your results */
{ echo $row['column1']; echo $row['column2']; } mysqli_free_result($result); }
} while (mysqli_next_result($link)); }来源:stack overflo