无法从CakePHP 3.4中的存储过程访问多个结果行集

时间:2018-08-24 10:02:03

标签: php mysql cakephp pdo cakephp-3.0

我正在尝试访问从CakePHP 3.4项目中的存储过程返回的多个结果集。这是我的代码:

$stmt = $db->execute("call mydatasp($paramlist)");
    $result = array();                     
    try{
            do
            {
                $rowset = $stmt->fetchAll('assoc');
                $result[]=$rowset;
            } while($stmt->nextRowset());
        }
        catch(Exception $e){}

我做了很多搜索,也通过了此链接,但是没有找到任何有用的数据。 How to call PDOStatement::nextRowset() in Cakephp 3

我该怎么做?

1 个答案:

答案 0 :(得分:0)

wait.until(expectedConditions.visibilityOfElementLocated(By.linkText("Google Cloud Platform Pricing ")));

假设存储过程$connection = ConnectionManager::get('default'); $sql = "CALL test()"; // name of stored procedure $rowSet = 1; //default value is 1,change according to stored procedure result set to access multiple result $stmt = $connection->execute($sql)->getInnerStatement()->getInnerStatement(); for ($i = 0; $i < $rowSet; $i++) { if($i > 0) $stmt->nextRowset(); $response[] = $stmt->fetchAll(PDO::FETCH_ASSOC); } print_r($response); 返回4个结果集,那么您需要修改test()的值,否则默认值为$rowSet = 4