前几天弄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

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.

WebStorm Mac version
Useful JavaScript development tools

Atom editor mac version download
The most popular open source editor

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software