php - Why this stored procedure doesn't work? -
it doesn't seem there problem, can't understand why doesn't return data.
this stored procedure:
delimiter $$ drop procedure if exists `test`.`get_products`$$ create procedure `test`.`get_products` ( out out_productname varchar(255) ) begin select productname out_productname products; end $$ delimiter ;
and how call it:
$rs = mysql_query( 'call get_products(@f)' ); $rs = mysql_query( 'select @f' ); while($row = mysql_fetch_assoc($rs)) { print_r($row); }
this doesn't quite answer question work around not use output parameter
delimiter $$ drop procedure if exists `test`.`get_products`$$ create procedure `test`.`get_products` ( ) begin select productname @f products; end $$ delimiter ; mysql_query( 'set @f = 0;' ); $rs = mysql_query( 'call get_products()' ); $rs = mysql_query( 'select @f' ); while($row = mysql_fetch_assoc($rs)) { print_r($row); }
@f maintained database , can accessed sql session, if remember correctly
also in event returning things while getting results stored procedure want use
$rs->close(); $connection->next_result();
connection whatever named connection string
Comments
Post a Comment