2

此代码在我的本地主机(Xampp,PHP 5.4)上正常工作,但是当我在服务器(Wamp,PHP 5.5)上部署此代码时,它会为$mysqli->multiquery().

这是我的代码:

if($mysqli->multi_query("CALL `wc_new_tyre_article` ('$season','$dimB','$dimQ','$dimD','$com_id','$adr_id')")){
            do{
                if($result = $mysqli->store_result( )){

                    while($row = $result->fetch_object( )){
                        if(isset($row->empty))
                            break 1;
                        $articleId = $row->ART_ID;
                        $ggrId = $row->GGR_ID;
                        $articles[] = $row;
                    }
                    $result->close();
                }
            }while($mysqli->next_result() && $mysqli->more_results());
            for($index = 0;$index<count($articles);$index++){
                $articleId = $articles[$index]->ART_ID;
                $ggrId = $articles[$index]->GGR_ID;
                if(!empty($articleId) && !empty($ggrId)){
                    if($stk_results = $mysqli->query("CALL `wc_get_stock` ('$articleId','$ggrId','$com_id')")){
                       while($rows = mysqli_fetch_object($stk_results)){
                           $articles[$index]->STOCK = $rows;
                           while($mysqli->next_result()){
                                if($l_result = $mysqli->store_result())
                                    $l_result->free();
                            }
                       }
                    }
                }
            }

            return $articles; 

根据上面的代码,我首先调用wc_new_tyre_article它返回多个结果集。使用这个结果,我调用另一个 SPwc_get_stock来获取另一个结果。

我已经尝试了所有可用的解决方案,但它们都不起作用。

我试过了error_reporting(E_ALL ^ E_STRICT)

4

1 回答 1

1

如果您正在执行 CALL 查询,这是否意味着您刚刚完成了 CREATE PROCEDURE 查询?我们可以看到这部分吗?在我们开始您的 multi_query 之前,是否有一些不同步的地方?你在运行 multi_query 之前检查过 $mysqli->error 吗?

我对 CALL 查询没有任何经验,但我在某处读到 1 个 CALL 查询可以返回 >1 个结果集。你的返回多少个结果集?您是否需要将 next_result 和 more_results 从 do while 条件中提取出来以正确处理 >1 个结果集?

于 2015-04-26T02:20:19.857 回答