Php_pdo calling stored procedures, returning parameters related issues

Source: Internet
Author: User
Php_pdo call stored procedure, return parameter problem
$stmt = $db->prepare ("Call Pro_test (?, @?)");
$stmt->bindparam (1, $name);
$stmt->bindparam (2, $return _value, PDO::P aram_str, 4000);


Insert a row
$name = ' Chengdu city ';
$stmt->execute ();

Print_r ($return _value);


Call the stored procedure, return the parameter is empty, do you have, view the database, has successfully added data,
Execute directly in the database
SET @n =-1;
Call Pro_test ("Ah is intended", @n);
Select @n;
All returned are the correct parameters.

Share to: more


------Solution--------------------
Database may return multiple result sets when calling a stored procedure
In order: The result of the basic Select, the result of stored procedure 1, the result of stored procedure 2 ....
Your SQL command This is call Pro_test (?, @?) No select so can only be in the second result set
If writing select Call Pro_test (?, @?) is located in the first result set
Of course, the environment of ten changeable, you do not really know exactly where the results of the rally
So we need to loop the reading
  do {
$rows = $stmt->fetchall (pdo::fetch_num);
if ($rows) {
Print_r ($rows);
}
} while ($stmt->nextrowset ());
  • 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.