Mysql procedure returns only one / first row
I am now trying to figure out 100 times the reason why my code only gives the first line as output. I made one procedure that selects all products and I named it in php like this:
$query = "CALL create_helper()";
$exec = mysql_query( $query, $connexion );
while($row = mysql_fetch_row($exec)) {
var_dump( $row );
}
CREATE PROCEDURE create_helper ()
BEGIN
DECLARE prod CURSOR FOR SELECT id FROM pC;
...
OPEN prod;
pd_loop: LOOP
FETCH pd INTO id_s;
IF finished = 1 THEN
LEAVE pd_loop;
END IF;
SELECT name, ag, pdt, pname FROM clt WHERE id = id_s;
...
END LOOP pd_loop;
CLOSE prod;
END;
The procedure in mysql works fine, but the only and only problem is in php. It always shows the first line.
+3
source to share
1 answer
Try it
Returns a numeric array of strings corresponding to the selected string, or FALSE if there are no more strings.
mysql_fetch_row () fetches one row of data from the result associated with the specified result ID. The string is returned as an array. Each column of results is stored at an array offset, starting at offset 0.
mysql_fetch_array()
Fetch a result row as an associative array, a numeric array and also it fetches by both associative & numeric array.
<?php
$query = "CALL create_helper()";
$exec = mysql_query( $query, $connexion );
while($row = mysql_fetch_array($exec))
{
var_dump($row);
}
?>
-1
source to share