Forum OpenACS Development: Re: db_multirow and db_foreach -unclobber

Collapse
Posted by Lars Pind on
A few comments ...

1) db_multirow doesn't clobber variables other than the ones that are named the same as your column.

2) I agree that using the same local variable for multiple purposes is bad practice, but the problem is not with the page design but with the system design.

I think that we've overloaded the local variables namespace. We stick the query variables from ad_page_contract there, we put the columns from our database procs there, and finally, we use the local variables to pass properties to the template.

I actually feel like all 3 of these need to be broken away from the local variables namespace somehow, since they're all part of a 'public API' of sorts, and thus you should have freedom in your choice of naming.

3) I also agree that db_foreach and db_multirow are modeled after foreach, and thus I can see the value of keeping the default behavior what it is now.

So if we could find a way to store query variables in a 'query::' namespace and properties in a 'property::' namespace, then maybe that would solve the problem better.

/Lars

Collapse
Posted by Andrew Piskorski on
Lars's "query::" and "property::" namespaces definitely sound like the best idea proposed so far. (Not that I've tried to implement it, though...)