问题描述
这不起作用:
$dbh = new PDO("dblib:host=xxxx;dbname=xxx", "xxxxx", "xxxxx");
$sth = $dbh->prepare("{exec wcweb_UserInfo(?)}");
$sth->bindParam(1, $name);
$sth->execute();
while($result = $sth->fetch(PDO::FETCH_ASSOC)) {
var_dump($result);
}
这也不起作用:
$dbh = new PDO("dblib:host=xxxxx;dbname=xxxx", "xxxxx", "xxxx");
$sth = $dbh->prepare("{call wcweb_UserInfo(?)}");
$sth->bindParam(1, $name);
$sth->execute();
while($result = $sth->fetch(PDO::FETCH_ASSOC)) {
var_dump($result);
}
这确实有效:
$dbh = new PDO("dblib:host=xxxxx;dbname=xxxx", "xxxxx", "xxxx");
$sth = $dbh->prepare("exec wcweb_UserInfo @userid=?");
$sth->bindParam(1, $name);
$sth->execute();
while($result = $sth->fetch(PDO::FETCH_ASSOC)) {
var_dump($result);
}
我使用2尝试了上面的方法,该方法在没有和没有大括号的情况下均不起作用,等等.我知道有人会说,好吧,以它的工作方式来做到这一点? ..问题是我正在将使用sqlsrv_query库的IIS应用程序从IIS服务器移植到Linux服务器.
I tried the above using 2 that did not work with and without the curly brackets, etc. I know some would say, well just do it the way it works? .. The problem is I am porting an exising application from an IIS Server using the sqlsrv_query library to a Linux server.
应用程序中的所有数据库调用均使用使用此方法的函数编写:{call wcweb_UserInfo(?)} ..没有指定任何参数名称,因此我将必须修改每个数据库调用以包括该参数名称.我的印象是,PHP5的PDO库可以进行相同的调用?
All of the database calls in the app are written in functions that use this method: {call wcweb_UserInfo(?)} .. None of the parameter names are specified, so I would have to modify every database call to include the parameter names. I was under the impression that the PDO library for PHP5 can do those same kind of calls?
帮助!我有做错什么吗,还是PDO无法拨打此类电话?
Help! Is there something I am doing wrong or is it just that PDO can't make those kinds of calls?
推荐答案
由于某些原因,它可行:
For some reason this works:
$sth = $dbh->prepare("exec wcweb_UserInfo ?");
$sth->bindParam(1, $name);
$sth->execute();
while($result = $sth->fetch(PDO::FETCH_ASSOC)) {
var_dump($result);
}
我也许可以忍受这个.有人知道为什么其他方法不起作用吗?库中有区别吗?
I might be able to live with this. Anyone know why the other methods do not work? Is it a difference in the libraries?
这篇关于从使用PDO的PHP调用存储过程到使用INPUT参数的MSSQL Server的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!