Forum OpenACS Development: Re: db_multirow and db_foreach -unclobber

Collapse
Posted by Tom Jackson on

In fact it should be clear to anyone who has been working with AOLserver's ns_db API: when you are processing rows, the caller's environment is visable. The new db_* API is just a nice wrapper around that API. The proc is just there to allow re-use of code, not to protect the tcl page from unsound programming practices. This is what uplevel is supposed to be used for. If you don't want to clobber the vars, they really should not have the same name on your tcl page in the first place. Using one var name for two distinct purposes is bad programming practice.

I haven't looked at the code for db_multirow, but if it clobbers vars you would not expect it to clobber, like a loop var, or something, that should be documented, and possibly changed, as this would be a bug waiting to surface.