I highly recommend using SQL::Abstract to help you generate your place holders. You give it some perlish syntax describing your "where" statement, it gives you back a SQL snippet and some bind variables. Very clean and easy to use.
I used to use DBIx::Abstract, which is similar, but I found it does a lot more than I need, it's slower, and it's gets tied to your database handle. (Although I think the author may currently be working on making it faster and able to work without a DB handle).
Also, look at using the RaiseError and PrintError attributes in DBI to help with your error handling. It's not clear from the code above that you are doing any. My favorite technique is to turn on RaiseError, which will cause DBI to die if there is an error. Then I wrap a whole block of DBI statements with an eval statement, and check the errors in one place. Of course, this works better if your database supports transactions and you can rollback after an error. :)
You may also be interested in looking into the prepare_cached method for additional performance gains.
-mark
In reply to Re: Understanding placeholders
by markjugg
in thread Understanding placeholders
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |