I need to retrieve the OUT Parameters from a MySQL Stored Procedure. I can't find anything that explains this (and makes sense to me).
try {
$dsn = 'mysql:dbname=db_name;host=localhost';
$dbh = new PDO($dsn, 'usr_name', 'password');
} catch (PDOException $e) {
echo 'Connection failed: ' . $e->getMessage();
}
$stmt = $dbh->prepare("CALL db.stprNewUser(:usrEmail,:newUserOK,:stprComment)");
$stmt->bindParam(':usrEmail', $tmpEmail, PDO::PARAM_STR);
$stmt->bindParam(':newUserOK', $newUserOK, PDO::PARAM_INT,1);
$stmt->bindParam(':stprComment', $stprComment, PDO::PARAM_STR,100);
$stmt->execute();
$outputArray = $dbh->query("select @newUserOK, @stprComment")->fetch(PDO::FETCH_ASSOC);
print "procedure returned [" . $outputArray['@newUserOK'] . $outputArray['@stprComment'] . "]\n";
I found the last two lines on another SO item, but it just returns NULL values.