note 12437 deleted from function.extract by jimw

From: Date: Sat, 08 Dec 2001 19:57:36 +0000
Subject: note 12437 deleted from function.extract by jimw
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-22152@lists.php.net to get a copy of this message
I have tried the methods suggested with extract. It's handy, except for this: Null fields in MYSQL result in unset array entries. That means that the "extract()" call will not overwrite the old value with the new value. One solution is to clear all the variables that could be null before running extract(). That means that you don't get the "less code" benefit. Another solution is to pass the hash (perhaps by reference) into a function, which gives you a scope and thus eliminates code when you have a great many fields. Often, you're best off saying: while (list($foo, $bar, $baz) = someSql_fetch_row()) { // Do something }

« previous php.notes (#22152) next »