Moderator: General Moderators
alexp wrote:Well, in the example I give, the variable is only used briefly on (essentially) one page so (to prevent session variable runaway) you'd have to register and unregister the session variable and you'd also have to get the multi-select results in and out of the variable every time the page was accessed (which would generally happen consecutively anyway). This way after that initial construction you don't actually have to write any more code.
I don't get why you guys are so pessimistic about this - in the situation I describe alone it seems to me that it is a neat trick and fairly obviously the most efficent (code wise at least) way of dealing with it. And it's really quite a common situation.
the·o·ry ( P ) Pronunciation Key (th-r, thîr)
n. pl. the·o·ries
A set of statements or principles devised to explain a group of facts or phenomena, especially one that has been repeatedly tested or is widely accepted and can be used to make predictions about natural phenomena.
The branch of a science or art consisting of its explanatory statements, accepted principles, and methods of analysis, as opposed to practice: a fine musician who had never studied theory.
A set of theorems that constitute a systematic view of a branch of mathematics.
Abstract reasoning; speculation: a decision based on experience rather than theory.
A belief or principle that guides action or assists comprehension or judgment: staked out the house on the theory that criminals usually return to the scene of the crime.
An assumption based on limited information or knowledge; a conjecture.
Usage: Theory, Hypothesis. A theory is a scheme of the relations subsisting between the parts of a systematic whole; an hypothesis is a tentative conjecture respecting a cause of phenomena.
alexp wrote:Well there's no point in arguing over how common wanting to pass this sort of array is. What I can say is that I'm currently working with php to handle a lot of forms adding data to a database and I've found the trick extremely useful over the last 24 hours. If you want to dismiss it because it's not generic enough for you then by all means do so.
I still don't understand why you'd want to, though, as I assume you're quite happy using, for instance, the mysql_ php functions even though they only work with mysql_.
alexp wrote:saying "I'm never going to use this because it's not generic enough even if there are places where it might be a 'better' solution" was a ridiculous argument.
It took me a while to realise it, but the CPU cycles which most need to be conserved are in the programmers head and not the web server.
My first priority is to create scripts which are easy to work with ie easy to modify if new program features are requested and easy to re-use in new programs. A generic solution is almost always better precisely because it's generic. I don't waste time trying to remember if it will work with a particular array or not, and if someone else is working on my script they don't waste time trying to figure out an obscure way of passing arrays.
Users browsing this forum: No registered users and 3 guests