PC Nerd Posted March 3, 2010 Share Posted March 3, 2010 Hi, I like the style of iteration over a MySQLi_Result object such as: while($row=$result->fetch_assoc()) {/* do stuff */} As oposed to something like a for loop with $result->num_rows etc... However how would I code such a function.. I'm not sure what the function ( such as in my case $reportData->fetch_row() ) would need to throw, return or otherwise "do" to quit the while loop and not cause infinite iterations. Thanks, PC_Nerd Link to comment https://forums.phpfreaks.com/topic/193962-how-to-write-a-mysqli_resultfetch_assoc-style-function/ Share on other sites More sharing options...
trq Posted March 3, 2010 Share Posted March 3, 2010 It would simply need to return false when there are no records left in the resource. Link to comment https://forums.phpfreaks.com/topic/193962-how-to-write-a-mysqli_resultfetch_assoc-style-function/#findComment-1020757 Share on other sites More sharing options...
PC Nerd Posted March 3, 2010 Author Share Posted March 3, 2010 Thanks Link to comment https://forums.phpfreaks.com/topic/193962-how-to-write-a-mysqli_resultfetch_assoc-style-function/#findComment-1020764 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.