// on remplace le parametre PDO par une variable de session SQL (@err en l'occurence) // et on selectionne cette variable apres l'appel de la procedure stockée $stmt = $dbh->prepare('CALL out_sp_create_user( :login, :pass, :name, :email, @err ); SELECT @err'); $stmt->setFetchMode(PDO::FETCH_ASSOC); $stmt->bindParam(':login', $login); $stmt->bindParam(':pass', $pass); $stmt->bindParam(':name', $name); $stmt->bindParam(':email', $email); // on enleve la ligne suivante qui est devenue inutile //$stmt->bindParam(':err', $err, PDO::PARAM_INT, 10); $stmt->execute(); // on enleve aussi l'affichage des erreurs, c'etait juste pour tester //$errInfo = $stmt->errorInfo(); //print( $errInfo[0] .' - '. $errInfo[1] .' - '. $errInfo[2] .' ' ); // et surtout, on rajoute ca apres: $stmt->nextRowset(); // permet de passer au resultat suivant $out = $stmt->fetch(); // on recupere l'unique ligne de resultat print( '@err = '. $out['@err'] ); // et on recupere la valeur de notre variable @err
$stmt = $dbh->prepare("CALL sp_create_user( ?, ?, ?, ?, ? );"); $stmt->bindParam(1, $login); $stmt->bindParam(2, $pass); $stmt->bindParam(3, $name); $stmt->bindParam(4, $email); $stmt->bindParam(5, $value, PDO::PARAM_INT|PDO::PARAM_INPUT_OUTPUT, 10); // Appel de la procédure stockée $stmt->execute(); $errInfo = $stmt->errorInfo(); print( $errInfo[0] .' - '. $errInfo[1] .' - '. $errInfo[2] .' '); print( "La procédure a retourné : $value\n" );
HY000 - 1414 - OUT or INOUT argument 5 for routine chat.sp_create_user is not a variable or NEW pseudo-variable in BEFORE trigger
La procédure a retourné :
HY000 - 1414 - OUT or INOUT argument 5 for routine chat.sp_create_user is not a variable or NEW pseudo-variable in BEFORE trigger
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question$value = 12345; $stmt = $dbh->prepare("CALL sp_create_user( ?, ?, ?, ?, ? );"); $stmt->bindParam(1, $login); $stmt->bindParam(2, $pass); $stmt->bindParam(3, $name); $stmt->bindParam(4, $email); $stmt->bindParam(5, $value, PDO::PARAM_INT|PDO::PARAM_INPUT_OUTPUT, 10); // Appel de la procédure stockée $stmt->execute(); $errInfo = $stmt->errorInfo(); print( $errInfo[0] .' - '. $errInfo[1] .' - '. $errInfo[2] .' '); print( "La procédure a retourné : $value\n" );
42000 - 1414 - OUT or INOUT argument 5 for routine chat.sp_create_user is not a variable or NEW pseudo-variable in BEFORE trigger
La procédure a retourné : 12345