mysqli - PHP - is it recommended to use mysqli_data_seek within a loop -


when looping through mysqli query usual way be:

$res = $db->query($sql); while($rs = $res->fetch_assoc()) {     echo $rs['field']; } 

i found out use mysqli_data_seek setting internal result pointer, change loop following:

$res = $db->query($sql); $records = $res->num_rows; ($i = 0; $i <= $records-1; $i++) {     mysqli_data_seek($res,$i); // set result pointer      $rs = mysqli_fetch_assoc($res);     echo $rs['field']; } 

i benchmarked both ways , couldn't see difference wondering - there drawbacks using second method?

thanks

php - recommended use mysqli_data_seek within loop

of course not.

are there drawbacks using second method?

sure. takes as twice more code first one.


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -