View Single Post
Old 11-16-2012, 08:27 PM   PM User | #10
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,187
Thanks: 59
Thanked 3,995 Times in 3,964 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
You can't use PHP variables *DIRECTLY*, but you can pass them in as parameters.

For example, using the getAndBumpCount SP that I created, you would invoke it from PHP via:

Code:
$sql = "call getAndBumpCount ('$name')";
$result = mysql_query( $sql );
You can pass in as many arguments as you wish to a Stored Procedure and then use them by name in the body of the procedure.

In my SP, I used
Code:
create procedure getAndBumpCount( nm varchar(20) )
so the argument $name would end up in the MySQL variable nm and you can then use nm wherever you want in the SP.

Some people use a naming convention for parameters. Such as P_NM, P_ID, P_Address, etc. Where the "P_" makes it clear that this variable is a "P"arameter to the stored procedure.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote