Quantcast
Channel: PHP - MySQL gets value of out parameter from a stored procedure - Stack Overflow
Viewing all articles
Browse latest Browse all 6

PHP - MySQL gets value of out parameter from a stored procedure

$
0
0

I have called a MySQL stored procedure from PHP using mysqli. This has one out parameter.

$rs = $mysqli->query("CALL addNewUser($name,$age,@id)");

Here, @id is the out parameter. Next, I fire the following query to get the value of the out parameter:

$rs2 = $mysqli->query("SELECT @id");while($row = $rs->fetch_object()){    echo var_dump($row);}

The output of var_dump is as follows.

object(stdClass)#5 (1) { ["@id"]=> string(6) "100026" }

So, now I want to retrieve the value of @id, which I am unable to. I tried $row[0]->{@id} but this gave following error:

PHP Fatal error: Cannot use object of type stdClass as array


Viewing all articles
Browse latest Browse all 6

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>