mssql_execute()
смотрим мануал:
After initializing a stored procedure
with mssql_init, and binding all the
parameters (and return value if needed)
with mssql_bind, you can execute the
statement with mssql_execute.
Parameters:
- stmt: statement resource obtained with
mssql_init.
From here, you can use any of the other
mssql_* functions to retrieve the
recordsets as if you had called
mssql_query. Any T-SQL error will also
be reported in the same way. The
variables passed by reference for OUTPUT
and RETVAL parameters will be filled
with the right values.
Now, an example:
if we have this procedure:
CREATE PROCEDURE [procedure]
(
@sval varchar(50) OUTPUT,
@intval int OUTPUT,
@floatval decimal(6,4) OUTPUT
) AS
if @intval is null
select \'@intval is null\' as answer
else
select \'@intval is NOT null\' as answer
set @sval=\'Hello \' + @sval
set @intval=@intval+1
set @floatval=@floatval+1
return 10
We can use this PHP code:
<?php
$conn=mssql_connect("myhost","user","pwd");
if ($conn) {
mssql_select_db("mydb",$conn);
$stmt=mssql_init("procedure",$conn);
mssql_bind($stmt,"RETVAL",&$val,SQLINT4);
$ival=11;
$fval=2.1416;
$sval="Frank";
mssql_bind($stmt,"@sval",&$sval,SQLVARCHAR,TRUE);
mssql_bind($stmt,"@intval",&$ival,SQLINT4,TRUE);
mssql_bind($stmt,"@floatval",&$fval,SQLFLT8,TRUE);
$result=mssql_execute($stmt);
$arr=mssql_fetch_row($result);
print ("Answer: " . $arr[0] . "
" );
print ("RETVAL = $val ; intval = $ival ; floatval = $fval ; string = $sval");
mssql_close($conn);
}
else print("ooops!");
?>