Jump to content
Killersites Community
Sign in to follow this  
Biske94

Whats the difference

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!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

×