存储过程
USE [testtbl]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[sptest]
@LeadID Bigint out
AS
insert into Lead (Name) values('test');
select @LeadID =@@IDENTITY;
//存储过程
<?php
$arraysql(array($_POST[],SQLSRV_PARAM_OUT));
$objFilter=new Filter();
$spCall="{call dbo.sptest(?)}";
$objFilter->InsertQuery($spCall,$arraysql);
?>
<?php
function InsertQuery($spCall,$parameter){
$serverName = ".";
$connectionInfo = array("Database"=>"php","UID"=>"","PWD"=>"");
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if(!$conn){
echo "Connection could not be established.\n";
die( print_r( sqlsrv_errors(), true));
sqlsrv_close($conn);
}
$resource=sqlsrv_prepare($conn, $spCall, $parameter);
sqlsrv_next_result($resource);
sqlsrv_fetch($resource);
//resqlsrv_get_field($resource,0);
// sqlsrv_close($conn);
}
?>
我没有粘贴所有内容,因为它太长了,那么如何从 LeadID 获取返回值?无论如何,我需要声明数组以将其发送到插入查询吗?我试过了,但我仍然没有得到 LeadID