如何使用ADOdb PHP库执行MSSQL存储过程? [英] How to execute a MSSQL stored procedure with ADOdb PHP Library?

查看:93
本文介绍了如何使用ADOdb PHP库执行MSSQL存储过程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

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

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.

谢谢

推荐答案

我只是研究了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.

这篇关于如何使用ADOdb PHP库执行MSSQL存储过程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆