I have created a procedure (with the PHPMyAdmin tool) which returns a table and two outputs. If I execute the procedure with the button "Execute" of PHPMyAdmin it sends this query:
SET @p0 = '12';
SET @p1 = '1';
CALL `getPhoneReview` (@p0 , @p1 , @p2 , @p3);
SELECT @p2 AS `PhoneCount` , @p3 AS `ReviewCount`;
Which returns what is expected (the table and the two outputs). However, if I copy that exact code and execute from the SQL section it only executes the last sentence:
CALL `getPhoneReview` (@p0 , @p1 , @p2 , @p3)
Which doesn't return anything.
It's happening as well while trying to retrieve the output values with PHP. I have this code:
$C = new MySQLi(...);
$Q = $C->query("CALL getPhoneReview(12, 1, @PhoneCount, @ReviewCount)");
/* Looping over $Q works fine */
$PhoneCount = $C->query("SELECT @PhoneCount AS PhC");
$PCO = $PhoneCount->fetch_object();
var_dump($PCO->PhC); /* Call to a member function fetch_object() on boolean */
Could anybody help me?
答案 0 :(得分:1)
您的代码存在两个问题。
$C->next_result()
;为了让其他查询被执行。