Jump to content

Whats the difference


Biske94

Recommended Posts

Hi i have encountered one quirk in PHP, and I was wandering if anyone can explain it to me.
So writing this code gives me infinite loop

public static function find_this_query($sql){
			global $Database;
			$result_set = $Database->queryFunction($sql);
			$theObjectArray = array();
			$var = $result_set->fetch_assoc(); // I put the whole array in $var
			while($row = $var){ // and then I put that here
				// some code here
			}
			return $theObjectArray;
		}

Buuuut this doesnt

public static function find_this_query($sql){
			global $Database;
			$result_set = $Database->queryFunction($sql);
			$theObjectArray = array();
			while($row = $result_set->fetch_assoc()){ // here I just put method and everything works fine
				// some code here
			}
			return $theObjectArray;
		}

So I just wanna know why.
Thanks nerdzzzz!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

Loading...
×
×
  • Create New...