Php 我的存储过程在测试时工作正常,但没有返回任何PDO
还有我的php代码Php 我的存储过程在测试时工作正常,但没有返回任何PDO,php,mysql,stored-procedures,pdo,Php,Mysql,Stored Procedures,Pdo,还有我的php代码 Set @req =CONCAT('Select name, id',Ptype,' from ',Ptype); IF Ptype = "Country" THEN SET @req = CONCAT(@req,' where idContinent=',Psurtypeid); ELSEIF Ptype="State" THEN SET @req = CONCAT(@req,' where idCountry=',Psurtypeid); ELSEIF P
Set @req =CONCAT('Select name, id',Ptype,' from ',Ptype);
IF Ptype = "Country" THEN
SET @req = CONCAT(@req,' where idContinent=',Psurtypeid);
ELSEIF Ptype="State" THEN
SET @req = CONCAT(@req,' where idCountry=',Psurtypeid);
ELSEIF Ptype="Area" THEN
SET @req = CONCAT(@req,' where idState=',Psurtypeid);
END IF;
PREPARE stmt FROM @req;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
当我调试并获得结果查询时,它看起来像这样调用AfficherLocationList('State',1)
,并且在Mysql Workbench和Php Myadmin中都可以正常工作
但是在我的代码中返回一个空数组…Add
$bd->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_异常)代码>在连接打开之后,如果您还没有这样做,请查看它是否会产生任何结果。加上,$bd
变量;我以前见过这样的情况,它是混合的,应该是$db
。确保这实际上是正确的变量,而不是错误显示提示的typo.Thx。它帮了我:)而且$bd变量只是法语中的$dbyour,不用客气。是的,我对bd
有一种感觉,我认为它代表“base de données”;-)
$strReq = "Call AfficherLocationList('$subtype'," . $result["id"] . ")";
$req = $bd->prepare($strReq);
$req->execute();
$arrayOptions = $req->fetchAll(PDO::FETCH_ASSOC);