How to Use output return values when php calls a stored procedure through pdo

Source: Internet
Author: User
How to Use output return values when php calls a stored procedure through pdo
Create procedure 'para _ out' (out id int) begin select 5 into id; SELECT id; END $ stmt = $ dbh-> prepare ("CALL para_out (?) "); $ Stmt-> bindParam (1, $ return_value, PDO: PARAM_INT, 8); // call the stored procedureif ($ stmt-> execute () = false) print_r ($ stmt-> errorInfo (); else print "procedure returned $ return_value \ n "; // returns Array ([0] => 42000 [1] => 1414 [2] => OUT or INOUT argument 1 for routine test. para_out is not a variable or NEW pseudo-variable in BEFORE trigger)


Reply to discussion (solution)

$ Stmt-> bindParam (1, $ return_value, PDO: PARAMINT | PDO: PARAM_INPUT_OUTPUT, 8 );

$ Stmt-> bindParam (1, $ return_value, PDO: PARAMINT | PDO: PARAM_INPUT_OUTPUT, 8 );

Same errors,

Your stored procedure does not declare the input parameter. how can I CALL para_out (?) What about it?

Your stored procedure does not declare the input parameter. how can I CALL para_out (?) What about it?

Ask how to write it and let it return 5. thank you,

You can get 10 points for every day.

Alas, no one answered ~~~~

People,

Waiting for answers

$ Stmt = $ dbh-> prepare ("CALL para_out (?) ");
Change
$ Stmt = $ dbh-> prepare ("CALL para_out (@?) ");
Try

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.