This has been done before in the CakePHP framework (see http://api.cakephp.o...b5a35dd428f5c81 and I'm sure numerous other PHP frameworks that I don't work extensively with as well), except that Cake didn't take advantage of PHP's OOP because it also wanted to be PHP 4 compatible. It just requires that you pass in the variables in a certain format (in Cake's case it's an array) and then parse based on the fields and values in that format. It is really quite flexible and makes saving data a lot faster than writing the same old INSERT functions. Especially in this case where the insert function is exceptionally huge, having a function like that would be a huge advantage.After thinking about it I can see the advantage of writing a script that does what you're talking about vujsa. Have a function like build_db_query or something that builds the actually query and returns it as a string perhaps. You pass a table name, and an array of values in an assoc array indexing the related tables in the fields. You could make it even more flexible and add flag to determine whether it's a select, insert, update, or delete statement. Just have a switch on the flag, then build the appropriate sql statement.
Hey hotsam!
I'd say for your firearms and reviews, you don't need a many-to-many relationship. After all, each review only has one firearm; each review wouldn't have multiple firearms, would they? Then each firearm would have many reviews, which would make sense. As for the business to firearm relationship, I'm not sure if a firearm can have many businesses--that would depend on the license, right? Aren't many firearms licensed so that they're only made by one business? (Then again, I'm not familiar with their creation...)
Everything else makes sense to me. :-) Good luck!





