I am trying to get the count from a procedure result. I have seen that you can create a temporary table and count it later. But when I add my procedure to the function, it stops working. Why is that?
$connection->query('
drop procedure if exists parents;
create procedure parents(in parent int(11),in name varchar(22))
begin
set @parent=parent;
drop temporary table if exists ids;
create temporary table ids(id int(11));
while @parent<>0 do
prepare statement from concat("select related into @parent from ",name," where id=?");
execute statement using @parent;
insert into ids(id) values(@parent);
end while;
select*from ids;
end;
drop function if exists counted;
create function counted(parent int(11),name varchar(22))
returns int(11)
begin
call parents(parent,name);
return (select count(*) from ids);
end;
');
$fetch=$connection->query('select counted(3,"category");')->fetchall();
I get a fetch boolean error.
query()in mysqli.