laravel调用sql server存储过程

Posted yuanxiaoping_21cn_com

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了laravel调用sql server存储过程相关的知识,希望对你有一定的参考价值。

alter proc [dbo].[aaa]
(
    @AgencyID int,--代理商ID
    @AdminID int --结算操作人ID(管理员ID)
)
as
begin
    select top 5 * from tusers
    return 5
end

 

$dbh = DB::connection()->getPdo();
$stmt = $dbh->prepare("EXEC aaa ?,?");//Web_pAgencyBalance_Single
 
$a = 1;
$b = 2;
 
$stmt->bindParam(1, $a, \PDO::PARAM_INT);
$stmt->bindParam(2, $b, \PDO::PARAM_INT);
 
$stmt->execute();
$s = $stmt->fetchAll(\PDO::FETCH_ASSOC);
//$s = $stmt->query("select @r");//->fetchAll(\PDO::FETCH_ASSOC);
print_r($c);
print_r($s);
 
结果
-------------------------------------------------------------------------------
0Array ( [0] => Array ( [UserID] => 7518 [UserName] => 12345678544 [Pass] => 4297f44b13955235245b2497399d7a93 [TwoPassword] => 4297f44b13955235245b2497399d7a93 [NickName] => 121123 [LogoID] => 0 [LogoFileMD5] => [Token] => [OnlineFlag] => 0 [Disabled] => 0 [Sex] => 0 [IsRobot] => 0 [AgencyID] => 1 [AgencyName] => admin [Salt] => [IsModifyTwoPassword] => 0 [BindAlipay] => [BindAlipayName] => [IsBindAlipay] => 0 ) [1] => Array ( [UserID] => 34946 [UserName] => 15618478590 [Pass] => d41d8cd98f00b204e9800998ecf8427e [TwoPassword] => d41d8cd98f00b204e9800998ecf8427e [NickName] => test111 [LogoID] => 0 [LogoFileMD5] => [Token] => [OnlineFlag] => 0 [Disabled] => 0 [Sex] => 0 [IsRobot] => 0 [AgencyID] => 1 [AgencyName] => admin [Salt] => [IsModifyTwoPassword] => 0 [BindAlipay] => [BindAlipayName] => [IsBindAlipay] => 0 ) [2] => Array ( [UserID] => 43016 [UserName] => 43016 [Pass] => 972dd7e894fe7fbc5844bc66d02e66c3 [TwoPassword] => 972dd7e894fe7fbc5844bc66d02e66c3 [NickName] => 43016 [LogoID] => 0 [LogoFileMD5] => [Token] => [OnlineFlag] => 0 [Disabled] => 0 [Sex] => 0 [IsRobot] => 0 [AgencyID] => 0 [AgencyName] => daili0001 [Salt] => [IsModifyTwoPassword] => 0 [BindAlipay] => [BindAlipayName] => [IsBindAlipay] => 0 ) [3] => Array ( [UserID] => 51894 [UserName] => 13061767771 [Pass] => 3333333 [TwoPassword] => 3333333 [NickName] => Reese‘s [LogoID] => 0 [LogoFileMD5] => [Token] => [OnlineFlag] => 0 [Disabled] => 0 [Sex] => 0 [IsRobot] => 0 [AgencyID] => 1 [AgencyName] => admin [Salt] => [IsModifyTwoPassword] => 1 [BindAlipay] => [BindAlipayName] => [IsBindAlipay] => 0 ) [4] => Array ( [UserID] => 53492 [UserName] => 53492 [Pass] => f7ad15746f953382379000261beba6a0 [TwoPassword] => f7ad15746f953382379000261beba6a0 [NickName] => 53492 [LogoID] => 0 [LogoFileMD5] => [Token] => [OnlineFlag] => 0 [Disabled] => 0 [Sex] => 0 [IsRobot] => 0 [AgencyID] => 0 [AgencyName] => daili0001 [Salt] => [IsModifyTwoPassword] => 0 [BindAlipay] => [BindAlipayName] => [IsBindAlipay] => 0 ) )

以上是关于laravel调用sql server存储过程的主要内容,如果未能解决你的问题,请参考以下文章

sql server 怎么服务器连接调用oracle的存储过程

如何在 SQL Server 中检查调用存储过程

在SQL Server2005中,下面调用存储过程的语句错误的是:

VBS 调用SQL Server加密存储过程提示:对象关闭时 不允许操作

sql server显示远程过程调用失败怎么办

oracle dblink调用SQL SERVER存储过程,有具体样例吗