我编写了一个 MySQL 存储过程,它应该给出 5 个不同的结果作为输出。该 SP 在 PhpMyAdmin 中运行良好。但是当我在 laravel 中使用以下语句调用这个 SP 时:
$response = DB::select('call spRebasedValues("1", "2", "100")');
那么它在输出中只给出一个结果。
尝试
$response = DB::statement('call spRebasedValues("1", "2", "100")');
试试这个
DB::select('call spRebasedValues(?, ?, ?)', [1,2,100])
在 laravel 10.5 或更高版本上,您可以只使用 selectResultsets()。
[$user_params,$user_notifications] = DB::selectResultsets("CALL your_procedure_name(?)", $param);
$user_params 是您的第一个结果表, $user_notifications 是你的第二个结果表