Jump to content

while or foreach


mga_ka_php

Recommended Posts

i see that they use array in getting records from the database.

 

while ( $row = @mysql_fetch_object( $this->result ) ) {
    $this->last_result[$num_rows] = $row;
    $num_rows++;
}

 

what if my records is 50,000. does array can hold that number of records, or does it use to much memory?

Link to comment
Share on other sites

Is this wordpress too:-

while ( $row = @mysql_fetch_object( $this->result ) ) {

 

Bad coding methods afoot here...

 

If it is, this is why I use a tiny text editor, so that I know what's going on, and don't get me started on DreamWeaver, ugh.

 

Original question: While loops are preferred for iterating through DB/Array records, for loops and foreach take more memory as you are assigning temporary memory whilst the loop completes, also, preferred to use functions OUTSIDE the for loop to then there is less over head involved parser side.

 

Rw

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.