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 Quote 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. Quote 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 Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.