mr.dunstan has asked for the wisdom of the Perl Monks concerning the following question:
## say I magically have a hash filled with the name value pairs from the form input and I add up the values of the 3 fields, and I get:<input type=checkbox name=col1 value=1>NEW <input type=checkbox name=col2 value=4>PENDING <input type=checkbox name=col3 value=9>CLOSED
Then from this 'bitmask' I can figure out which criteria to add to my query, using a hash like so ...$sum = $form{'col1'} + $form{'col2'} + $form{'col3'};
... and voila, now I have my extra sql argument to tack onto my query.%possibleSQLargs = { 1 => "and table.column = 'NEW'"; 4 => "and table.column = 'PND'"; 9 => "and table.column = 'CLS'"; 5 => "and (table.column = 'NEW' or table.column = 'PND')"; 10 => "and (table.column = 'NEW' or table.column = 'CLS')"; 13 => "and (table.column = 'PND' or table.column = 'CLS')"; 15 => "and (table.column = 'NEW' or table.column = 'PND' or ta +ble.column = 'CLS')"; }; $extraqueryarg = $possibleSQLargs{'$sum'};
Edit: chipmunk 2001-06-27
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: generating various sql arguments dynamically, and bon crack/b
by chromatic (Archbishop) on Jun 28, 2001 at 03:04 UTC | |
by mr.dunstan (Monk) on Jun 28, 2001 at 03:12 UTC | |
|
Re: generating various sql arguments dynamically, and bon crack/b
by runrig (Abbot) on Jun 28, 2001 at 03:03 UTC |