Calling a stored procedure with output parameters using mysqli

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
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           |
1 row in set (0.00 sec)

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

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


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...?

Site Timeline