如何使用 ADOdb PHP 库执行 MSSQL 存储过程?

发布于 2024-12-29 09:28:45 字数 2158 浏览 0 评论 0原文

我已按照 ADOdb 文档 中的说明进行操作,我正在尝试在 sql server 2008 数据库上执行存储过程,如下所示:

$stmt = $db->PrepareSP('usp_insert_aweber_list');

$db->InParameter($stmt,$id,'List_ID',false,SQLINT4);
$db->InParameter($stmt,$name,'Name',255,SQLVARCHAR);
$db->InParameter($stmt,$campaigns_collection_link,'Campaign_Collections_Link',255,SQLVARCHAR);
$db->InParameter($stmt,$custom_fields_collection_link,'Custom_Fields_Collection_Link',255,SQLVARCHAR);
$db->InParameter($stmt,$http_etag,'HTTP_Etag',255,SQLVARCHAR);
$db->InParameter($stmt,$resource_type_link,'Resource_Type_Link',255,SQLVARCHAR);
$db->InParameter($stmt,$self_link,'Self_Link',255,SQLVARCHAR);
$db->InParameter($stmt,$subscribers_collection_link,'Subscribers_Collection_Link',255,SQLVARCHAR);
$db->InParameter($stmt,$total_subscribers,'Total_Subscribers',false,SQLINT4);
$db->InParameter($stmt,$total_subscribed_subscribers,'Total_Subscribed_Subscribers',false,SQLINT4);
$db->InParameter($stmt,$total_subscribers_subscribed_today,'Total_Subscribers_Subscribed_Today',false,SQLINT4);
$db->InParameter($stmt,$total_subscribers_subscribed_yesterday,'Total_Subscribers_Subscribed_Yesterday',false,SQLINT4);
$db->InParameter($stmt,$total_unconfirmed_subscribers,'Total_Unconfirmed_Subscribers',false,SQLINT4);
$db->InParameter($stmt,$total_unsubscribed_subscribers,'Total_Unsubscribed_Subscribers',false,SQLINT4);
$db->InParameter($stmt,$web_form_split_tests_collection_link,'Web_Form_Split_Tests_Collection_Link',255,SQLVARCHAR);
$db->InParameter($stmt,$web_forms_collection_link,'Web_Forms_Collection_Link',255,SQLVARCHAR);

$rs = $db->Execute($stmt);

if (!$rs){
    print $db->ErrorMsg();
    echo '<br /><br />';
}

上面的代码仅输出以下错误消息:

[Microsoft][ODBC SQL Server Driver][SQL Server]Procedure or function 'usp_insert_aweber_list' expects parameter '@List_ID', which was not supplied.

我相信我已经在第一个中提供了 List_ID 参数$db->InParameter() 调用。如果我错了请纠正我。在任何响应“在参数名称前面添加@”之前,文档指出不需要它,我已经尝试过它,它会导致相同的错误消息。

谢谢

I've followed the instructions in the ADOdb documentation and I'm trying to execute a stored procedure on a sql server 2008 database like so:

$stmt = $db->PrepareSP('usp_insert_aweber_list');

$db->InParameter($stmt,$id,'List_ID',false,SQLINT4);
$db->InParameter($stmt,$name,'Name',255,SQLVARCHAR);
$db->InParameter($stmt,$campaigns_collection_link,'Campaign_Collections_Link',255,SQLVARCHAR);
$db->InParameter($stmt,$custom_fields_collection_link,'Custom_Fields_Collection_Link',255,SQLVARCHAR);
$db->InParameter($stmt,$http_etag,'HTTP_Etag',255,SQLVARCHAR);
$db->InParameter($stmt,$resource_type_link,'Resource_Type_Link',255,SQLVARCHAR);
$db->InParameter($stmt,$self_link,'Self_Link',255,SQLVARCHAR);
$db->InParameter($stmt,$subscribers_collection_link,'Subscribers_Collection_Link',255,SQLVARCHAR);
$db->InParameter($stmt,$total_subscribers,'Total_Subscribers',false,SQLINT4);
$db->InParameter($stmt,$total_subscribed_subscribers,'Total_Subscribed_Subscribers',false,SQLINT4);
$db->InParameter($stmt,$total_subscribers_subscribed_today,'Total_Subscribers_Subscribed_Today',false,SQLINT4);
$db->InParameter($stmt,$total_subscribers_subscribed_yesterday,'Total_Subscribers_Subscribed_Yesterday',false,SQLINT4);
$db->InParameter($stmt,$total_unconfirmed_subscribers,'Total_Unconfirmed_Subscribers',false,SQLINT4);
$db->InParameter($stmt,$total_unsubscribed_subscribers,'Total_Unsubscribed_Subscribers',false,SQLINT4);
$db->InParameter($stmt,$web_form_split_tests_collection_link,'Web_Form_Split_Tests_Collection_Link',255,SQLVARCHAR);
$db->InParameter($stmt,$web_forms_collection_link,'Web_Forms_Collection_Link',255,SQLVARCHAR);

$rs = $db->Execute($stmt);

if (!$rs){
    print $db->ErrorMsg();
    echo '<br /><br />';
}

The above bit of code just outputs the following error message:

[Microsoft][ODBC SQL Server Driver][SQL Server]Procedure or function 'usp_insert_aweber_list' expects parameter '@List_ID', which was not supplied.

I've believe I've provided the List_ID param in my first $db->InParameter() call. Correct me if I'm wrong. Before any responds with 'Add an @ in front of the param name' the documentation notes it's not needed and I've tried it already and it results in the same error message.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

违心° 2025-01-05 09:28:45

我刚刚查看了 ADOdb 5.13(并且 5.14 和 5.15 变更日志没有提到该区域的任何更改)代码,似乎 MSSQL 的 ODBC 驱动程序不支持将参数绑定到准备好的语句,并且在您尝试时不会产生任何错误去做它。

I just looked into ADOdb 5.13 (and 5.14 & 5.15 changelog does not mention any changes in that area) code and it seems that ODBC driver for MSSQL does not support binding parameters to the prepared statements and does not produce any error while you are trying to do it.

梦纸 2025-01-05 09:28:45

我已经看到这适用于早期版本的 SQL Server,但仅限于使用“mssql”驱动程序(而不是 odbc_mssql 或 ado_mssql)时。

I've seen this working against earlier versions of SQL Server, but only when using the 'mssql' driver (and not odbc_mssql or ado_mssql).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文