This is a general question having to do with proper programming technique. Specifically it has to do with how to handle a large number of DB queries in a large PHP site.
The site I am designing is composed with many different php pages and each page have mostly unique DB queries (inserts, updates, deletes). Up to this point I have been writing each query in the page that needs the query. Now that the site has become much bigger, this is becomming inefficient and hard to maintain. If a DB table field changes name, for example, I have to seach through all the php pages to find the pages that have queries on that table and update them.
I've seen a couple ways to remedy this and was wonder which was the best way. One way i saw was to put all the queries into an array and put the array in a seperate PHP page. Then you have all your php pages require the page with the array. This way there's only one page to look at in order to change any query. Is there any limit to the PHP array size? Is it inefficient/slow to import this array into all my PHP pages even though each maybe may only use 2 or 3 of the queries in the array? Are there any better ways to accomplish this?
Thanks for the advise.