Re: mysql_fetch_assoc and extract
| From: | CPT John W. Holmes | Date: | Mon, 14 Apr 2003 15:40:03 +0000 |
| Subject: | Re: mysql_fetch_assoc and extract | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-143789@lists.php.net to get a copy of this message | ||
> Using extract after using mysql_fetch_assoc is handy for variables, but
> if no row if returned, you've got a problem. First you get an error on
> the extract needing an array, then you've got the same variables from
> the previous loop.
>
> It would be very handy if extract could do a complete prefix unset
> first. For example, if my prefix were "my", it would unset every last
> variable starting with $my_ . And it would also not return an error on
> empty.
>
> Or if that's asking for too much, having a wildcard unset would be
> awesome ... unset($my_*).
>
> Anyone have a special function doing just that? Thanks.
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...