I'm working on an MS SQL database at work. We're in early development, and I'm playing around with PHP while a coworker of mine is using ASP.NET. In the end, we'll probably combine our efforts and stick with one or the other. For this reason, I thought it would be wise to do as much programming in stored procedures on the database as possible.
So I'm currently working on this bit where the user uploads a text file, the data gets rearranged, and inserted into a table on the server. Now I'm basically faced with three options:
- Do all of the rearranging in PHP and build the query string and execute it.
- Insert the data as-is into a different table and call a stored procedure to rearrange it and insert it into the bigger target table.
- Simply pass the data as parameters into a stored procedure that does all the manipulating and joining at one time.
From what I've read so far, I understand that option 1 is probably not so good. Really my question is, is option 3 too far in the other direction? I have a feeling it would be more difficult, but it would be the most portable and I wouldn't have that extra table with the yet-to-be-manipulated data sitting on the server. Or is option 2 the way to go since it will likely make the most sense to anyone who comes after me trying to analyze what my code is doing?