前几天弄PHP调用MSSQL存储过程,搞了许久,网上资料也少之又少(特别是基于ADODB的)。
那在这我就举个基于ADODB调用MSSQL存储过程的例子吧,希望对人有所帮助。
/*
Test out params - works in PHP 4.2.3 and 4.3.3 and 4.3.8 but not 4.3.0:
CREATE PROCEDURE at_date_interval
@days INTEGER,
@start VARCHAR(20) OUT,
@end VARCHAR(20) OUT
AS
BEGIN
set @start = CONVERT(VARCHAR(20), getdate(), 101)
set @end =CONVERT(VARCHAR(20), dateadd(day, @days, getdate()), 101 )
END
GO
*/
$db->debug=1;
$stmt = $db->PrepareSP('at_date_interval');
$days = 10;
$begin_date = '';
$end_date = '';
$db->InParameter($stmt,$days,'days', 4, SQLINT4); //这里97xxoo是In参数
$db->OutParameter($stmt,$begin_date,'start', 20, SQLVARCHAR ); //这是存储过程返 回值,可直接访问$begin_date所得到。
$db->OutParameter($stmt,$end_date,'end', 20, SQLVARCHAR ); //同上
$db->Execute($stmt);
echo $begin_date;
echo $end_date;
这样就OK了,这简单的例子相信都能看得懂,其他的原理也是相同的。
在这里还要注意的是:$begin_date ,$end_date 一样要先赋个空值,否则结果取不到值。这就是害我搞了N久的原因了。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.
