Calling a stored procedure with output parameters using mysqli

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • evan.lavidor@gmail.com

    Calling a stored procedure with output parameters using mysqli

    Hi all,

    Forgive me if this topic has been discussed before. I've been doing
    some searching and have yet to come across the answer I'm looking for.


    I'm new to PHP, and I'm trying to call a MySQL stored procedure (using
    mysqli) that has both input and output parameters. I have no problems
    passing in the relevant params, but calling the output params is
    confusing me. Most of the examples I see online deal with returning
    recordsets, which I am not doing.

    As a super-basic example, I've created the following sproc in MySQL:
    CREATE PROCEDURE testproc(OUT p_testvar varchar(50)) BEGIN SET
    p_testvar = 'HELLO WORLD!'; END

    When I call this from MySQL I can do the following:
    mysql> call testproc (@a);
    mysql> select @a;
    +--------------+
    | @a |
    +--------------+
    | HELLO WORLD! |
    +--------------+
    1 row in set (0.00 sec)


    But how would I do a similar call in PHP to retrieve the output
    parameter?

    Thanks very much for any help, samples, or resources that anyone can
    point me towards.

    Evan

  • evan.lavidor@gmail.com

    #2
    Re: Calling a stored procedure with output parameters using mysqli

    Sorry... a couple of more details:
    Running MySQL version 5.0.18
    Running PHP 5.1.2

    I've looked at using PDO instead of mysqli, but it looks like MySQL 5
    isn't supported by PDO...?

    Comment

    Working...