案例:存储过程看起来像:
DROP PROCEDURE IF EXISTS `XofferCommon`.`getCdpc`;<br>
DELIMITER $$<br>
CREATE PROCEDURE `XofferCommon`.`getCdpc` (IN in_city_ID INT, OUT out_country_id INT, OUT out_district_id INT, OUT out_provence_id INT, OUT out_city_id INT)<br>
BEGIN<br>
DECLARE city_ID INT DEFAULT in_city_ID;<br>
SELECT t.Id, d.Id, p.Id, c.Id INTO out_country_id, out_district_id, out_provence_id, out_city_id FROM ((tblCity AS c INNER JOIN tblProvence AS p ON c.tblProvence_Id = p.ID) INNER JOIN tblDistrict AS d ON p.tblDistrict_Id = d.ID) INNER JOIN tblCountry AS t ON -d.tblCountry_Id = t.ID WHERE c.id = city_ID;<br>
END$$<br>
DELIMITER ;<br><br>
<br>---------------------------------------------------
Input: int referring to in_city_id<br>
Output: 4 x int country district provence and city id's<br>
---------------------------------------------------<br>
Php:我想调用该过程并将4个返回的对象存储到4个变量中
if ($res = $mysqli->query( 'CALL getCdpc(1321,@co,@di,@pr,@ci);SELECT @co,@di,@pr,@ci'))<br>
{<br>
while($row = $res->fetch_object())<br>
{<br>
print($row);<br>
}<br>
$res->close();<br>
}<br>
else<br>
{<br>
print "<br> no result given <br>";<br>
}<br>
<br>
Result:<br>
-------<br>
我总是得到零行
<br>
<br>
More info:<br>
----------<br>
in mysql sql the results get returned when I do:<br>
->call xoffercommon.getCdpc(1321,@co,@di,@pr,@ci);<br>
->select @co,@di,@pr,@ci;<br>
=> @co @di @pr @ci<br>
1 2 3 4<br>
<br>
Question:<br>
---------<br>
我是否必须运行 2 个查询、对过程的调用和对该结果的选择?
有没有办法在一行中运行它?
...请帮助我找不到解决问题的方法,已经尝试在程序中返回,但这仅在函数中允许。已经 2 周过去了...通过阅读/反复试验学到了很多东西 ;-),但没有任何东西可以破解这个案例....