存储过程不返回带有PDO语句的记录

时间:2021-01-13 10:56:52

Just started working on Stored Procedures, but not sure if I've completely miss understood them ... Here's a simple one I'm trying to get working, but it doesn't output anything:

刚开始研究存储过程,但不确定我是否完全错过了解它们......这是一个简单的我正在努力工作,但它没有输出任何东西:

CREATE procedure testprocedure (userID INT)
DETERMINISTIC
COMMENT "Test procedure"
BEGIN
    SELECT * FROM user WHERE ID=userID;
END

Php:

<?php
    include 'dbconnect.php';
    $stmt = $db->prepare("CALL testprocedure(:userid)");
    $stmt->bindValue(':userid',1,PDO::PARAM_INT);
    $stmt->execute();
    $row=$stmt->fetchAll(PDO::FETCH_ASSOC);
    print_r($row);
?>

Just outputs array()

只输出数组()

But, if I use testprocedure(1) in Workbench, it returns a row

但是,如果我在Workbench中使用testprocedure(1),它将返回一行

Any help appreciated :D

任何帮助表示赞赏:D

1 个解决方案

#1


0  

It was me being stupid ...

这是我愚蠢的......

The user I was using to call the Stored Procedure didn't have the 'Execute' privilege ...

我用来调用存储过程的用户没有'执行'权限......

Simple as that Lol ...

简单就像那个哈哈......

On the bright side, I still have one third of my hair left

从好的方面来说,我仍有三分之一的头发留下

#1


0  

It was me being stupid ...

这是我愚蠢的......

The user I was using to call the Stored Procedure didn't have the 'Execute' privilege ...

我用来调用存储过程的用户没有'执行'权限......

Simple as that Lol ...

简单就像那个哈哈......

On the bright side, I still have one third of my hair left

从好的方面来说,我仍有三分之一的头发留下