In a new post today, Maggie Nelson starts with the wrong way to do something - passing an array from PHP to a database - and works backward to make it all right.
It would be really useful to have an easy way to pass arrays as bound parameters to queries or procedures from PHP. This would be especially useful if you're letting Oracle handle most of your data manipulating (as you should).
She includes an example of how she's like it to work. Sadly, it doesn't but there are some ways that a developer could get close. Here's her process:
- No queries in loops, please!
- In the ideal world...
- Put all your DML in stored procedures.
- The list_pkg package
- list_pkg in your procedure
- list_pkg in your PHP
- Leveraging list_pkg
The list_pkg is based around this article from AskTom.