-1
當我運行MySQL控制檯上執行以下步驟爲test1,我得到如何從PHP調用存儲過程並獲得結果?
「」 MySQL返回的查詢結果爲空(即零行)。」
Delimiter $$
create procedure test1()
BEGIN
BLOCK1: begin
declare v_col1 int(10);
declare no_more_rows1 boolean default FALSE;
declare cursor1 cursor for
select content_id
from topic_list where topic_id=1;
declare continue handler for not found
set no_more_rows1 = TRUE;
open cursor1;
LOOP1: loop
fetch cursor1
into v_col1;
if no_more_rows1 then
close cursor1;
leave LOOP1;
end if;
BLOCK2: begin
declare v_col2 int(10);
declare no_more_rows2 boolean default FALSE;
declare cursor2 cursor for
select content_id
from content_upvotes
where u_id_upvoter = 1;
declare continue handler for not found
set no_more_rows2 = TRUE;
open cursor2;
LOOP2: loop
fetch cursor2
into v_col2;
if no_more_rows2 then
close cursor2;
leave LOOP2;
end if;
select count(*) as mynum from (SELECT *from content_upvotes where content_id=v_col1) t1 join (select u_id_upvoter as user_id from content_upvotes where content_id= v_col2) t2 on t1.u_id_upvoter=t2.user_id ;
end loop LOOP2;
end BLOCK2;
end loop LOOP1;
end BLOCK1;
end $$
DELIMITER ;
我如何把它從PHP?所以我得到輸出mynum變量爲每個變量(v_col1,每個v_col2)變量
downvoted你只是因爲你在SO上註冊了2個帳戶,然後重複了這個問題:http://stackoverflow.com/questions/34816018/would-this-procedure-calculate-the-no-of-rows-how-do -i-呼叫此-過程往復 – crafter