&引用;命令不同步;你可以';“现在不要运行此命令”;在PHP中使用storedproc时
在这篇文章结束之前,或者在这个问题上我参考了一个现有的参考文献,这里有一个我参考过的文档列表,以及我为此复习过的其他线程。我知道我错过了一些非常简单的东西,但我一辈子都看不到我面前的东西。我现在真是束手无策 由于目前我一次只能发布2个链接,所以我选择了前两个有压力的链接,我已经查过了 在第一组的第一次查询之前&引用;命令不同步;你可以';“现在不要运行此命令”;在PHP中使用storedproc时,php,mysql,mysqli,Php,Mysql,Mysqli,在这篇文章结束之前,或者在这个问题上我参考了一个现有的参考文献,这里有一个我参考过的文档列表,以及我为此复习过的其他线程。我知道我错过了一些非常简单的东西,但我一辈子都看不到我面前的东西。我现在真是束手无策 由于目前我一次只能发布2个链接,所以我选择了前两个有压力的链接,我已经查过了 在第一组的第一次查询之前 object(mysqli)#1 (18) { ["affected_rows"]=> int(-1) ["client_info"]=> string(6
object(mysqli)#1 (18) {
["affected_rows"]=>
int(-1)
["client_info"]=>
string(6) "5.5.52"
["client_version"]=>
int(50552)
["connect_errno"]=>
int(0)
["connect_error"]=>
NULL
["errno"]=>
int(0)
["error"]=>
string(0) ""
["field_count"]=>
int(2)
["host_info"]=>
string(25) "Localhost via UNIX socket"
["info"]=>
NULL
["insert_id"]=>
int(0)
["server_info"]=>
string(23) "5.5.43-0ubuntu0.12.04.1"
["server_version"]=>
int(50543)
["stat"]=>
string(147) "Uptime: 4702713 Threads: 3 Questions: 19875140 Slow queries: 504 Opens: 30587 Flush tables: 1 Open tables: 128 Queries per second avg: 4.226"
["sqlstate"]=>
string(5) "00000"
["protocol_version"]=>
int(10)
["thread_id"]=>
int(1143580)
["warning_count"]=>
int(0)
}
object(mysqli)#1 (18) {
["affected_rows"]=>
int(10)
["client_info"]=>
string(6) "5.5.52"
["client_version"]=>
int(50552)
["connect_errno"]=>
int(0)
["connect_error"]=>
NULL
["errno"]=>
int(0)
["error"]=>
string(0) ""
["field_count"]=>
int(2)
["host_info"]=>
string(25) "Localhost via UNIX socket"
["info"]=>
NULL
["insert_id"]=>
int(0)
["server_info"]=>
string(23) "5.5.43-0ubuntu0.12.04.1"
["server_version"]=>
int(50543)
["stat"]=>
string(52) "Commands out of sync; you can't run this command now"
["sqlstate"]=>
string(5) "HY000"
["protocol_version"]=>
int(10)
["thread_id"]=>
int(1143586)
["warning_count"]=>
int(0)
}
object(mysqli)#1 (18) {
["affected_rows"]=>
int(0)
["client_info"]=>
string(6) "5.5.52"
["client_version"]=>
int(50552)
["connect_errno"]=>
int(0)
["connect_error"]=>
NULL
["errno"]=>
int(2014)
["error"]=>
string(52) "Commands out of sync; you can't run this command now"
["field_count"]=>
int(2)
["host_info"]=>
string(25) "Localhost via UNIX socket"
["info"]=>
NULL
["insert_id"]=>
int(0)
["server_info"]=>
string(23) "5.5.43-0ubuntu0.12.04.1"
["server_version"]=>
int(50543)
["stat"]=>
string(52) "Commands out of sync; you can't run this command now"
["sqlstate"]=>
string(5) "HY000"
["protocol_version"]=>
int(10)
["thread_id"]=>
int(1143613)
["warning_count"]=>
int(0)
}
object(mysqli)#1 (18) {
["affected_rows"]=>
int(0)
["client_info"]=>
string(6) "5.5.52"
["client_version"]=>
int(50552)
["connect_errno"]=>
int(0)
["connect_error"]=>
NULL
["errno"]=>
int(2014)
["error"]=>
string(52) "Commands out of sync; you can't run this command now"
["field_count"]=>
int(2)
["host_info"]=>
string(25) "Localhost via UNIX socket"
["info"]=>
NULL
["insert_id"]=>
int(0)
["server_info"]=>
string(23) "5.5.43-0ubuntu0.12.04.1"
["server_version"]=>
int(50543)
["stat"]=>
string(52) "Commands out of sync; you can't run this command now"
["sqlstate"]=>
string(5) "HY000"
["protocol_version"]=>
int(10)
["thread_id"]=>
int(1143626)
["warning_count"]=>
int(0)
}
在第一组的第一次查询之后
object(mysqli)#1 (18) {
["affected_rows"]=>
int(-1)
["client_info"]=>
string(6) "5.5.52"
["client_version"]=>
int(50552)
["connect_errno"]=>
int(0)
["connect_error"]=>
NULL
["errno"]=>
int(0)
["error"]=>
string(0) ""
["field_count"]=>
int(2)
["host_info"]=>
string(25) "Localhost via UNIX socket"
["info"]=>
NULL
["insert_id"]=>
int(0)
["server_info"]=>
string(23) "5.5.43-0ubuntu0.12.04.1"
["server_version"]=>
int(50543)
["stat"]=>
string(147) "Uptime: 4702713 Threads: 3 Questions: 19875140 Slow queries: 504 Opens: 30587 Flush tables: 1 Open tables: 128 Queries per second avg: 4.226"
["sqlstate"]=>
string(5) "00000"
["protocol_version"]=>
int(10)
["thread_id"]=>
int(1143580)
["warning_count"]=>
int(0)
}
object(mysqli)#1 (18) {
["affected_rows"]=>
int(10)
["client_info"]=>
string(6) "5.5.52"
["client_version"]=>
int(50552)
["connect_errno"]=>
int(0)
["connect_error"]=>
NULL
["errno"]=>
int(0)
["error"]=>
string(0) ""
["field_count"]=>
int(2)
["host_info"]=>
string(25) "Localhost via UNIX socket"
["info"]=>
NULL
["insert_id"]=>
int(0)
["server_info"]=>
string(23) "5.5.43-0ubuntu0.12.04.1"
["server_version"]=>
int(50543)
["stat"]=>
string(52) "Commands out of sync; you can't run this command now"
["sqlstate"]=>
string(5) "HY000"
["protocol_version"]=>
int(10)
["thread_id"]=>
int(1143586)
["warning_count"]=>
int(0)
}
object(mysqli)#1 (18) {
["affected_rows"]=>
int(0)
["client_info"]=>
string(6) "5.5.52"
["client_version"]=>
int(50552)
["connect_errno"]=>
int(0)
["connect_error"]=>
NULL
["errno"]=>
int(2014)
["error"]=>
string(52) "Commands out of sync; you can't run this command now"
["field_count"]=>
int(2)
["host_info"]=>
string(25) "Localhost via UNIX socket"
["info"]=>
NULL
["insert_id"]=>
int(0)
["server_info"]=>
string(23) "5.5.43-0ubuntu0.12.04.1"
["server_version"]=>
int(50543)
["stat"]=>
string(52) "Commands out of sync; you can't run this command now"
["sqlstate"]=>
string(5) "HY000"
["protocol_version"]=>
int(10)
["thread_id"]=>
int(1143613)
["warning_count"]=>
int(0)
}
object(mysqli)#1 (18) {
["affected_rows"]=>
int(0)
["client_info"]=>
string(6) "5.5.52"
["client_version"]=>
int(50552)
["connect_errno"]=>
int(0)
["connect_error"]=>
NULL
["errno"]=>
int(2014)
["error"]=>
string(52) "Commands out of sync; you can't run this command now"
["field_count"]=>
int(2)
["host_info"]=>
string(25) "Localhost via UNIX socket"
["info"]=>
NULL
["insert_id"]=>
int(0)
["server_info"]=>
string(23) "5.5.43-0ubuntu0.12.04.1"
["server_version"]=>
int(50543)
["stat"]=>
string(52) "Commands out of sync; you can't run this command now"
["sqlstate"]=>
string(5) "HY000"
["protocol_version"]=>
int(10)
["thread_id"]=>
int(1143626)
["warning_count"]=>
int(0)
}
在第二集的第二次查询之前
object(mysqli)#1 (18) {
["affected_rows"]=>
int(-1)
["client_info"]=>
string(6) "5.5.52"
["client_version"]=>
int(50552)
["connect_errno"]=>
int(0)
["connect_error"]=>
NULL
["errno"]=>
int(0)
["error"]=>
string(0) ""
["field_count"]=>
int(2)
["host_info"]=>
string(25) "Localhost via UNIX socket"
["info"]=>
NULL
["insert_id"]=>
int(0)
["server_info"]=>
string(23) "5.5.43-0ubuntu0.12.04.1"
["server_version"]=>
int(50543)
["stat"]=>
string(147) "Uptime: 4702713 Threads: 3 Questions: 19875140 Slow queries: 504 Opens: 30587 Flush tables: 1 Open tables: 128 Queries per second avg: 4.226"
["sqlstate"]=>
string(5) "00000"
["protocol_version"]=>
int(10)
["thread_id"]=>
int(1143580)
["warning_count"]=>
int(0)
}
object(mysqli)#1 (18) {
["affected_rows"]=>
int(10)
["client_info"]=>
string(6) "5.5.52"
["client_version"]=>
int(50552)
["connect_errno"]=>
int(0)
["connect_error"]=>
NULL
["errno"]=>
int(0)
["error"]=>
string(0) ""
["field_count"]=>
int(2)
["host_info"]=>
string(25) "Localhost via UNIX socket"
["info"]=>
NULL
["insert_id"]=>
int(0)
["server_info"]=>
string(23) "5.5.43-0ubuntu0.12.04.1"
["server_version"]=>
int(50543)
["stat"]=>
string(52) "Commands out of sync; you can't run this command now"
["sqlstate"]=>
string(5) "HY000"
["protocol_version"]=>
int(10)
["thread_id"]=>
int(1143586)
["warning_count"]=>
int(0)
}
object(mysqli)#1 (18) {
["affected_rows"]=>
int(0)
["client_info"]=>
string(6) "5.5.52"
["client_version"]=>
int(50552)
["connect_errno"]=>
int(0)
["connect_error"]=>
NULL
["errno"]=>
int(2014)
["error"]=>
string(52) "Commands out of sync; you can't run this command now"
["field_count"]=>
int(2)
["host_info"]=>
string(25) "Localhost via UNIX socket"
["info"]=>
NULL
["insert_id"]=>
int(0)
["server_info"]=>
string(23) "5.5.43-0ubuntu0.12.04.1"
["server_version"]=>
int(50543)
["stat"]=>
string(52) "Commands out of sync; you can't run this command now"
["sqlstate"]=>
string(5) "HY000"
["protocol_version"]=>
int(10)
["thread_id"]=>
int(1143613)
["warning_count"]=>
int(0)
}
object(mysqli)#1 (18) {
["affected_rows"]=>
int(0)
["client_info"]=>
string(6) "5.5.52"
["client_version"]=>
int(50552)
["connect_errno"]=>
int(0)
["connect_error"]=>
NULL
["errno"]=>
int(2014)
["error"]=>
string(52) "Commands out of sync; you can't run this command now"
["field_count"]=>
int(2)
["host_info"]=>
string(25) "Localhost via UNIX socket"
["info"]=>
NULL
["insert_id"]=>
int(0)
["server_info"]=>
string(23) "5.5.43-0ubuntu0.12.04.1"
["server_version"]=>
int(50543)
["stat"]=>
string(52) "Commands out of sync; you can't run this command now"
["sqlstate"]=>
string(5) "HY000"
["protocol_version"]=>
int(10)
["thread_id"]=>
int(1143626)
["warning_count"]=>
int(0)
}
第二组第二次查询后
object(mysqli)#1 (18) {
["affected_rows"]=>
int(-1)
["client_info"]=>
string(6) "5.5.52"
["client_version"]=>
int(50552)
["connect_errno"]=>
int(0)
["connect_error"]=>
NULL
["errno"]=>
int(0)
["error"]=>
string(0) ""
["field_count"]=>
int(2)
["host_info"]=>
string(25) "Localhost via UNIX socket"
["info"]=>
NULL
["insert_id"]=>
int(0)
["server_info"]=>
string(23) "5.5.43-0ubuntu0.12.04.1"
["server_version"]=>
int(50543)
["stat"]=>
string(147) "Uptime: 4702713 Threads: 3 Questions: 19875140 Slow queries: 504 Opens: 30587 Flush tables: 1 Open tables: 128 Queries per second avg: 4.226"
["sqlstate"]=>
string(5) "00000"
["protocol_version"]=>
int(10)
["thread_id"]=>
int(1143580)
["warning_count"]=>
int(0)
}
object(mysqli)#1 (18) {
["affected_rows"]=>
int(10)
["client_info"]=>
string(6) "5.5.52"
["client_version"]=>
int(50552)
["connect_errno"]=>
int(0)
["connect_error"]=>
NULL
["errno"]=>
int(0)
["error"]=>
string(0) ""
["field_count"]=>
int(2)
["host_info"]=>
string(25) "Localhost via UNIX socket"
["info"]=>
NULL
["insert_id"]=>
int(0)
["server_info"]=>
string(23) "5.5.43-0ubuntu0.12.04.1"
["server_version"]=>
int(50543)
["stat"]=>
string(52) "Commands out of sync; you can't run this command now"
["sqlstate"]=>
string(5) "HY000"
["protocol_version"]=>
int(10)
["thread_id"]=>
int(1143586)
["warning_count"]=>
int(0)
}
object(mysqli)#1 (18) {
["affected_rows"]=>
int(0)
["client_info"]=>
string(6) "5.5.52"
["client_version"]=>
int(50552)
["connect_errno"]=>
int(0)
["connect_error"]=>
NULL
["errno"]=>
int(2014)
["error"]=>
string(52) "Commands out of sync; you can't run this command now"
["field_count"]=>
int(2)
["host_info"]=>
string(25) "Localhost via UNIX socket"
["info"]=>
NULL
["insert_id"]=>
int(0)
["server_info"]=>
string(23) "5.5.43-0ubuntu0.12.04.1"
["server_version"]=>
int(50543)
["stat"]=>
string(52) "Commands out of sync; you can't run this command now"
["sqlstate"]=>
string(5) "HY000"
["protocol_version"]=>
int(10)
["thread_id"]=>
int(1143613)
["warning_count"]=>
int(0)
}
object(mysqli)#1 (18) {
["affected_rows"]=>
int(0)
["client_info"]=>
string(6) "5.5.52"
["client_version"]=>
int(50552)
["connect_errno"]=>
int(0)
["connect_error"]=>
NULL
["errno"]=>
int(2014)
["error"]=>
string(52) "Commands out of sync; you can't run this command now"
["field_count"]=>
int(2)
["host_info"]=>
string(25) "Localhost via UNIX socket"
["info"]=>
NULL
["insert_id"]=>
int(0)
["server_info"]=>
string(23) "5.5.43-0ubuntu0.12.04.1"
["server_version"]=>
int(50543)
["stat"]=>
string(52) "Commands out of sync; you can't run this command now"
["sqlstate"]=>
string(5) "HY000"
["protocol_version"]=>
int(10)
["thread_id"]=>
int(1143626)
["warning_count"]=>
int(0)
}
一个从我的查询中输出的示例结果集,通常每个Eng有8个,但我认为最好缩短它
Array
(
[1st Set] => Array
(
[Eng1] => Array
(
[Live] => 24
[Score] => 47
[Res] => 102
)
[Eng2] => Array
(
[Live] => 22
[Score] => 39
[Res] => 79
)
[Eng3] => Array
(
[Live] => 24
[Score] => 33
[Res] => 54
)
[Eng4] => Array
(
[Live] => 11
[Score] => 31
[Res] => 46
)
[Eng5] => Array
(
[Live] => 10
[Score] => 25
[Res] => 51
)
)
[2nd Set] =>
)
问题中的storedproc-
CREATE DEFINER=`chris_test`@`%` PROCEDURE `countSingleStat`(
IN statTableLoc VARCHAR(20),
IN statCountLoc VARCHAR(20),
IN statIDLoc VARCHAR(20),
IN teamID INT(2),
IN singleTeam INT(1),
IN rangeStart DATE,
IN rangeEnd DATE,
IN dateRequired INT(1),
IN dataHandling INT(1))
countStat:BEGIN
-- Set passed attributes as uservar so these can be used with concat
SET @statTableLoc = statTableLoc;
SET @statCountLoc = statCountLoc;
SET @statIDLoc = statIDLoc;
SET @rangeStart = rangeStart;
SET @rangeEnd = rangeEnd;
SET @teamID = teamID; -- Excluding or requesting a specific team
-- Example completed query
-- SELECT e.displayname, SUM(r.sessions) AS totalres FROM rescue r JOIN engineers e ON e.id=r.engid
-- WHERE r.date BETWEEN '2017-01-06' AND '2017-01-07'
-- AND NOT e.id=0
-- GROUP BY e.id
-- ORDER BY totalres DES
-- start of query required to find single stat
-- datahandling specifies how the data is being present, currently only string & sum listed
CASE dataHandling
WHEN 0 THEN
SET @qry = concat('SELECT e.displayname, ', @statTableLoc ,'.', @statCountLoc ,' AS string');
WHEN 1 THEN
SET @qry = concat('SELECT e.displayname, sum(', @statTableLoc ,'.', @statCountLoc ,') AS total');
END CASE;
-- Is a date start/end required for query.
CASE dateRequired
WHEN 0 THEN
SET @qry = concat(@qry,' FROM ', @statTableLoc ,' JOIN engineers e ON e.id=', @statTableLoc ,'.engid WHERE');
WHEN 1 THEN
SET @qry = concat(@qry,' FROM ', @statTableLoc ,' JOIN engineers e ON e.id=', @statTableLoc ,'.engid WHERE ', @statTableLoc ,'.date BETWEEN \'', @rangeStart ,'\' AND \'', @rangeEnd ,'\' AND');
END CASE;
-- Has a single team been requested or a team been excluded from results
CASE singleTeam
WHEN 0 THEN
SET @qry = concat(@qry,' NOT e.teamid=', @teamID ,' GROUP BY e.id ORDER BY');
WHEN 1 THEN
SET @qry = concat(@qry,' e.teamid=', @teamID ,' GROUP BY e.id ORDER BY');
END CASE;
CASE dataHandling
WHEN 0 THEN
SET @qry = concat(@qry,' string DESC');
WHEN 1 THEN
SET @qry = concat(@qry,' total DESC');
END CASE;
PREPARE statsCount FROM @qry;
EXECUTE statsCount;
DROP PREPARE statsCount;
END
// Set query for specifed stat & it's assoicated settings. Request between specific dates if required
$qry = "CALL SingleStat('". $statsTable ."','". $statsRequired ."','". $statTableEngID ."',". $teamID .",". $excludeORinclude .",'". $dateRangeStart ."','". $dateRangeEnd ."',". $dateRequired .",". $dataHandling .")";
try
{ // run query
$result = $db->query($qry);
echo $db->error;
}
catch (Exception $e)
{
echo $db->error;
vardumpCount($e);
}
// do we have results?
if($result->num_rows > 0)
{
// loop through results
while ($resultsArray = $result->fetch_assoc())
{
/* LOTS OF CODE GOES HERE */
}
#####
// do we have any results remaining to be processed.
if ($db->next_result())
{
if ($results = $db->use_result())
{
while ($row = $result->fetch_assoc())
{
echo "<pre>";
print_r($row);
echo "</pre>";
echo "</br>-----------</br></br>";
}
}
}
#####
return $engStatArray;
}
有问题的PHP(5)-
CREATE DEFINER=`chris_test`@`%` PROCEDURE `countSingleStat`(
IN statTableLoc VARCHAR(20),
IN statCountLoc VARCHAR(20),
IN statIDLoc VARCHAR(20),
IN teamID INT(2),
IN singleTeam INT(1),
IN rangeStart DATE,
IN rangeEnd DATE,
IN dateRequired INT(1),
IN dataHandling INT(1))
countStat:BEGIN
-- Set passed attributes as uservar so these can be used with concat
SET @statTableLoc = statTableLoc;
SET @statCountLoc = statCountLoc;
SET @statIDLoc = statIDLoc;
SET @rangeStart = rangeStart;
SET @rangeEnd = rangeEnd;
SET @teamID = teamID; -- Excluding or requesting a specific team
-- Example completed query
-- SELECT e.displayname, SUM(r.sessions) AS totalres FROM rescue r JOIN engineers e ON e.id=r.engid
-- WHERE r.date BETWEEN '2017-01-06' AND '2017-01-07'
-- AND NOT e.id=0
-- GROUP BY e.id
-- ORDER BY totalres DES
-- start of query required to find single stat
-- datahandling specifies how the data is being present, currently only string & sum listed
CASE dataHandling
WHEN 0 THEN
SET @qry = concat('SELECT e.displayname, ', @statTableLoc ,'.', @statCountLoc ,' AS string');
WHEN 1 THEN
SET @qry = concat('SELECT e.displayname, sum(', @statTableLoc ,'.', @statCountLoc ,') AS total');
END CASE;
-- Is a date start/end required for query.
CASE dateRequired
WHEN 0 THEN
SET @qry = concat(@qry,' FROM ', @statTableLoc ,' JOIN engineers e ON e.id=', @statTableLoc ,'.engid WHERE');
WHEN 1 THEN
SET @qry = concat(@qry,' FROM ', @statTableLoc ,' JOIN engineers e ON e.id=', @statTableLoc ,'.engid WHERE ', @statTableLoc ,'.date BETWEEN \'', @rangeStart ,'\' AND \'', @rangeEnd ,'\' AND');
END CASE;
-- Has a single team been requested or a team been excluded from results
CASE singleTeam
WHEN 0 THEN
SET @qry = concat(@qry,' NOT e.teamid=', @teamID ,' GROUP BY e.id ORDER BY');
WHEN 1 THEN
SET @qry = concat(@qry,' e.teamid=', @teamID ,' GROUP BY e.id ORDER BY');
END CASE;
CASE dataHandling
WHEN 0 THEN
SET @qry = concat(@qry,' string DESC');
WHEN 1 THEN
SET @qry = concat(@qry,' total DESC');
END CASE;
PREPARE statsCount FROM @qry;
EXECUTE statsCount;
DROP PREPARE statsCount;
END
// Set query for specifed stat & it's assoicated settings. Request between specific dates if required
$qry = "CALL SingleStat('". $statsTable ."','". $statsRequired ."','". $statTableEngID ."',". $teamID .",". $excludeORinclude .",'". $dateRangeStart ."','". $dateRangeEnd ."',". $dateRequired .",". $dataHandling .")";
try
{ // run query
$result = $db->query($qry);
echo $db->error;
}
catch (Exception $e)
{
echo $db->error;
vardumpCount($e);
}
// do we have results?
if($result->num_rows > 0)
{
// loop through results
while ($resultsArray = $result->fetch_assoc())
{
/* LOTS OF CODE GOES HERE */
}
#####
// do we have any results remaining to be processed.
if ($db->next_result())
{
if ($results = $db->use_result())
{
while ($row = $result->fetch_assoc())
{
echo "<pre>";
print_r($row);
echo "</pre>";
echo "</br>-----------</br></br>";
}
}
}
#####
return $engStatArray;
}
//为指定的统计及其关联设置设置查询。如果需要,在特定日期之间请求
$qry=“调用SingleStat(‘“$statsTable.”、‘“$statsRequired.”、‘“$statTableEngID.”、‘$teamID.”、‘$excludeORinclude.”、‘“$dateRangeStart.”、‘“$dateRangeEnd.”、‘$dateRequired.”、‘$dateRequired.”、‘$dataHandling.”);
尝试
{//运行查询
$result=$db->query($qry);
echo$db->错误;
// Set query for specifed stat & it's assoicated settings. Request between specific dates if required
$qry = "CALL SingleStat('". $statsTable ."','". $statsRequired ."','". $statTableEngID ."',". $teamID .",". $excludeORinclude .",'". $dateRangeStart ."','". $dateRangeEnd ."',". $dateRequired .",". $dataHandling .")";
try
{ // run query
$result = $db->query($qry);
echo $db->error;
}
catch (Exception $e)
{
echo $db->error;
vardumpCount($e);
}
// do we have results?
if($result->num_rows > 0)
{
while($db->more_results() && $db->next_result())
{
// loop through results
while ($resultsArray = $result->fetch_assoc())
{
/* LOTS OF CODE GOES HERE */
}
}
return $engStatArray;
}
}
捕获(例外$e)
{
echo$db->错误;
// Set query for specifed stat & it's assoicated settings. Request between specific dates if required
$qry = "CALL SingleStat('". $statsTable ."','". $statsRequired ."','". $statTableEngID ."',". $teamID .",". $excludeORinclude .",'". $dateRangeStart ."','". $dateRangeEnd ."',". $dateRequired .",". $dataHandling .")";
try
{ // run query
$result = $db->query($qry);
echo $db->error;
}
catch (Exception $e)
{
echo $db->error;
vardumpCount($e);
}
// do we have results?
if($result->num_rows > 0)
{
while($db->more_results() && $db->next_result())
{
// loop through results
while ($resultsArray = $result->fetch_assoc())
{
/* LOTS OF CODE GOES HERE */
}
}
return $engStatArray;
}
vardumpCount(e美元);
}
//我们有结果吗?
如果($result->num_rows>0)
{
//循环浏览结果
而($resultsArray=$result->fetch_assoc())
{
/*这里有很多代码*/
}
#####
//我们还有什么结果需要处理吗。
如果($db->next_result())
{
如果($results=$db->use_result())
{
而($row=$result->fetch_assoc())
{
回声“;
// Set query for specifed stat & it's assoicated settings. Request between specific dates if required
$qry = "CALL SingleStat('". $statsTable ."','". $statsRequired ."','". $statTableEngID ."',". $teamID .",". $excludeORinclude .",'". $dateRangeStart ."','". $dateRangeEnd ."',". $dateRequired .",". $dataHandling .")";
try
{ // run query
$result = $db->query($qry);
echo $db->error;
}
catch (Exception $e)
{
echo $db->error;
vardumpCount($e);
}
// do we have results?
if($result->num_rows > 0)
{
while($db->more_results() && $db->next_result())
{
// loop through results
while ($resultsArray = $result->fetch_assoc())
{
/* LOTS OF CODE GOES HERE */
}
}
return $engStatArray;
}
打印(行);
回声“;
// Set query for specifed stat & it's assoicated settings. Request between specific dates if required
$qry = "CALL SingleStat('". $statsTable ."','". $statsRequired ."','". $statTableEngID ."',". $teamID .",". $excludeORinclude .",'". $dateRangeStart ."','". $dateRangeEnd ."',". $dateRequired .",". $dataHandling .")";
try
{ // run query
$result = $db->query($qry);
echo $db->error;
}
catch (Exception $e)
{
echo $db->error;
vardumpCount($e);
}
// do we have results?
if($result->num_rows > 0)
{
while($db->more_results() && $db->next_result())
{
// loop through results
while ($resultsArray = $result->fetch_assoc())
{
/* LOTS OF CODE GOES HERE */
}
}
return $engStatArray;
}
回声“------------”;
// Set query for specifed stat & it's assoicated settings. Request between specific dates if required
$qry = "CALL SingleStat('". $statsTable ."','". $statsRequired ."','". $statTableEngID ."',". $teamID .",". $excludeORinclude .",'". $dateRangeStart ."','". $dateRangeEnd ."',". $dateRequired .",". $dataHandling .")";
try
{ // run query
$result = $db->query($qry);
echo $db->error;
}
catch (Exception $e)
{
echo $db->error;
vardumpCount($e);
}
// do we have results?
if($result->num_rows > 0)
{
while($db->more_results() && $db->next_result())
{
// loop through results
while ($resultsArray = $result->fetch_assoc())
{
/* LOTS OF CODE GOES HERE */
}
}
return $engStatArray;
}
}
}
}
#####
返回$engStatArray;
}
因此,在一步一步地完成这一步骤并在一些测试代码中尝试了不同的东西之后,我成功地解决了我的问题。我仍然不太明白为什么它是这样工作的&而不是另一种,因为它正在经历同样的过程。我能看到的唯一区别是它会一直尝试,直到它的计算结果为false&包含$db->more_results()
出于某种原因,我们既没有提供相关代码,也没有标记错误发生的行,因此我们几乎无法确定我到底遗漏了什么?我在我的标题中声明了错误,该错误在mysqli对象的vardumps中可见。然后我提供了有问题的storedproc&关于如何处理每个查询的相关PHP代码?我已经将我的php剥离到与mysqli相关的基础知识上,试图只提供我认为需要的东西。php是一个更大的函数的一部分,大部分只是处理输出&将其添加到数组中。在函数外部,它位于将设置传递到函数/storedproc的
foreach
循环内。错误发生在第一个循环中,但仅显示在[“stat”]
中,直到在第二个循环中出现第二组查询时,错误完全消失。我确实怀疑是storedproc中的某个原因导致了错误,但我看不出这是如何“不同步”的当我没有运行任何实际语句,直到它完成构建查询后结束。