How to execute a MSSQL stored procedure with ADOdb PHP Library?

て烟熏妆下的殇ゞ 提交于 2019-12-11 07:37:12

问题


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


回答1:


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.




回答2:


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).



来源:https://stackoverflow.com/questions/9038004/how-to-execute-a-mssql-stored-procedure-with-adodb-php-library

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!