samedi 25 avril 2015

mysql procedure call with out parameter not working in PHP


I have created a test procedure (for the sake of example to get this working) called test_proc like below -

    DELIMITER $$

    CREATE DEFINER=`tloken`@`%` PROCEDURE `test_proc`(In user_id varchar(100), OUT message varchar(1000))
    BEGIN

    set message ='OK';
    END

and calling it from php test page like below -

$sso = $_GET['sso'];
$ret = '';
echo $RepExecutQry = "call test_proc(?, ?)";

$stmt = $conn->Prepare($RepExecutQry);


$stmt->bindParam(1, $sso, PDO::PARAM_INT, 10);
$stmt->bindParam(2, $ret, PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT, 32);

$stmt->execute();

print "Values of bound parameters _after_ CALL:\n";
print "  1: {$ret} 2: {$sso}\n"     

Also tried the solution with bindValue(), but the procedure doesn't return anything. $conn is a pdo connection object and created properly, tested with var_dump($conn) already. Sorry to create the duplicate question, but all other suggestions on the forum for similar problem I tried already and they were not working. any suggestions would be valued and appreciated. Thank you


Aucun commentaire:

Enregistrer un commentaire