gpt4 book ai didi

php - multi_query 不在循环内运行

转载 作者:行者123 更新时间:2023-11-29 23:49:01 24 4
gpt4 key购买 nike

我放入另一个查询中的多重查询无法运行。内部查询中的存储过程未执行。多重查询单独运行良好,但在循环内却运行不佳。冷你请检查一下,为什么 InnerQuery 不在循环内执行?

 <?php
include ("../mysqli.php");
if (mysqli_connect_errno()) {
printf("Connection error: %s\n", mysqli_connect_error());
exit();
}

# Check Start Time
$time1 = microtime(true);

## Start
if ($DBquery = $mysqli->query("SELECT `id` FROM `Universe`")) {
while($obj = $DBquery->fetch_object()){
$id = $obj->id;
echo "Start with Product-ID: " . $id . "<br>";

# Defining Inner Query
$DBInnerQuery = "
SET @CATEGORY := (SELECT ....);
SET @Date := (SELECT ...
CALL `PROCEDURE1`;

SET @COUNTRY := (SELECT ....);
CALL `PROCEDURE2`;
...
";

# Inner Query does not run and I don't know why:
if ($mysqli->multi_query($DBInnerQuery)) {
$time2 = microtime(true) - $time1;
echo "Scan for Product-Id " . $id . " solved in "
. round ($time2, 4) . " seconds<br>";
}

}
}
echo "End of Product Check." . "<br>";
?>

最佳答案

同时,我已经解决了这个问题:

 # Defining Inner Query
CALL `PROCEDURE1;`;

# Multi Query
if ($mysqli->multi_query($DBInnerQuery)) {
echo "<hr>" . "Scan for all Items solved." . "<br>";
}

$time2 = microtime(true) - $time;
echo "Used Time: "
. round ($time, 4) . " Seconds<br>";

echo "End." . "<br>";

关于php - multi_query 不在循环内运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25758212/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com