php - $stmt->fetch() returns false when trying to call a stored procedure -


when i'm trying call stored procedure using php, $stmt->fetch(); returns false reason.

i've been looking @ this question reference, can not seem work properly.

i have following php code snippet tries call stored procedure in mysql database:

$password = "pass"; $username = "name";  $stmt = $conn->prepare("call sp_login(:password,:username,@retval)");        $stmt->bindparam(':password', $password, pdo::param_str); $stmt->bindparam(':username',$username, pdo::param_str);        $stmt->execute();  var_dump($stmt); //prints "object(pdostatement)[2] public 'querystring' => string 'call sp_login(:password,:username,@retval)' (length=42)"  $res = $stmt->fetch();  var_dump($res); //prints "boolean false"  $retval = $res['retval'];  var_dump($retval); //prints null 

my stored procedure code:

delimiter @@ drop procedure sp_login @@ create procedure sp_login ( in in_password varchar(255), in in_username varchar(255), out res int) begin     select 1     res     användare     lösenord = in_password     , användarnamn = in_username; end @@  delimiter ;  

why $stmt->fetch(); returning false? when call procedure directly in mysql workbench this:

call sp_login('pass','name',@res); select @res; 

it works intended (it returns 1).


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -