how to return an output stored procedures MYSQL PHP

0

Some time ago I am looking for the web on how I can return an OUT in MYSQL with stored procedures in php.

PHP

mysqli_select_db($conexion, $database_conexion);
$query_DatosWeb = sprintf("CALL genera_sesion()");
$DatosWeb = mysqli_query($conexion, $query_DatosWeb) or die(mysqli_error($conexion));
$row_DatosWeb = mysqli_fetch_assoc($DatosWeb);
$totalRows_DatosWeb = mysqli_num_rows($DatosWeb);
    
asked by Matias 05.08.2018 в 01:52
source

1 answer

0

It seems to me that there is no native method of mysqli to capture the output parameters of a stored procedure, as an alternative you would have to create a dynamic variable and incorporate it in the first call of the method, to later retrieve the result with a select, below I leave you a small example.

$stmt = $mysqli->prepare("CALL genera_sesion(@param)");
$stmt->execute();
$select = $mysqli->query('SELECT @param');
$result = $select->fetch_assoc();
$param = $result['@param'];
var_dump($param);

I'm not sure how to adapt it to your case, since I think you have some custom methods, that's why I've put a generic example. In this link speak A little more in depth about this topic by the way, although it's in English.

    
answered by 05.08.2018 в 03:38