Calling Stored Procedure with Out Parameter Using PDO
This question explores an issue encountered while trying to call a stored procedure with an output parameter using PDO in PHP. The error message "SQLSTATE[42000]: Syntax error or access violation: 1414 OUT or INOUT argument 1 for routine mydb.proc_OUT is not a variable or NEW pseudo-variable in BEFORE trigger" arises.
To resolve this issue, the following steps are suggested:
$dbh->query("CALL SomeStoredProcedure($someInParameter1, $someInParameter2, @someOutParameter)"); $dbh->query("SELECT @someOutParameter");
$stmt = $dbh->prepare("CALL SomeStoredProcedure(?, ?)"); $stmt ->execute(array($someInParameter1, $someInParameter2));
By implementing these solutions, the error related to the output parameter in the stored procedure should be resolved.
The above is the detailed content of How to Resolve 'OUT or INOUT argument ... is not a variable' Error When Calling Stored Procedures with PDO?. For more information, please follow other related articles on the PHP Chinese website!