Re: mysql_fetch_assoc and extract

From: Date: Mon, 14 Apr 2003 17:52:02 +0000
Subject: Re: mysql_fetch_assoc and extract
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-143821@lists.php.net to get a copy of this message
> > Sounds like you have a problem in the overall logic. If a row is not > > returned, then you shouldn't be doing any processing or calling extract, > > right? How are you retrieving the row? I don't understand why people use > > extract() as it is, anyhow... So what if you have to type $row['name'] > > instead of just $name? It makes your code easier for others to follow and > > doesn't waste memory by making all of the extra variables... > > > > ---John Holmes... > > > > How much less memory does an array with say 10 elements take up compared > with 10 variables? Is it 1/10th? Or is it the same? You've got the array in memory, plus you take up extra time to extract each of the keys into it's own variable. That's taking up memory and time. The memory issue is probably negligible unless you're serving thousands of pages a second, but nonetheless... Just get in the habit of typing $row['name'] when you need it. > Currently I do error checking to see if the row returned anything, I'm > just saying it would be convenient if you didn't have to go to the trouble. Yeah, it'd be convenient, but it doesn't make sense. Show how you're doing it now, maybe there is a better method. ---John Holmes...

« previous php.general (#143821) next »