Is it possible to access an OUT
variable from an SP called through mysqli without returning it via SELECT
one way or another? I had a good look and tried the code here but it always needs a result set called within or after the SP to work.
Consider this code:
SQL:
DELIMITER $
# DROP PROCEDURE IF EXISTS outVar$
CREATE PROCEDURE outVar(OUT myVar TINYINT(1))
BEGIN
SET myVar = 1;
END$
DELIMITER ;
CALL outVar(@myVar);
SELECT @myVar;
PHP:
<?php
$Conn = new mysqli("127.0.0.1", "root", "123456789", "test");
$RResult = $Conn->query("CALL outVar(@myVar);");
print_r($RResult->fetch_assoc());
?>
This returns the following:
Fatal error: Call to a member function fetch_assoc() on boolean in C:\xampp\htdocs\phpTest.php on line 7
Because there are no results returned in tabular form, fair enough. So am I correct in assuming that while OUT
is elegant within mysql it's of no use in the mysqli context without the help of a result set leaving OUT
redundant in this context? If not I'd love to know how to do it.
Thanks,
James