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