MargateSteve Posted January 16, 2011 Share Posted January 16, 2011 Eventually I will have around 5 or 6 queries that will be replicated in several different pages, albeit with a slight difference in each (generally just a change in the WHERE part). I have been thinking about placing these common queries in a separate file and calling that file with an 'include' on the pages the query is needed. My two questions are.... Would this be more beneficial than place the query in the page itself and would there be any downside (as in loading times) if I placed all of these queries in one external file (ie. would this cause all the queries to load each time. Thanks in advance for any advice. Steve Quote Link to comment https://forums.phpfreaks.com/topic/224616-duplicating-common-queries/ Share on other sites More sharing options...
ignace Posted January 16, 2011 Share Posted January 16, 2011 Could you post those 5/6 queries? Generally though you shouldn't need a separate file for each query as you can wrap these in functions that can be called whenever needed. Quote Link to comment https://forums.phpfreaks.com/topic/224616-duplicating-common-queries/#findComment-1160288 Share on other sites More sharing options...
MargateSteve Posted January 16, 2011 Author Share Posted January 16, 2011 I am not at the stage where I have the queries ready, but am just thinking ahead. There is, however, on query that I had help with at http://www.phpfreaks.com/forums/php-coding-help/using-a-generated-row-number-in-another-query that is a good example. In that post I mentioned a League Standings Table. I will have the whole standings in one page whilst, as per that thread, on each teams individual page I would want a smaller version based around that teams rank. Elsewhere I will want a version that only shows records for the last five games of each team, versions that will show just the top five or bottom five teams and various ORDER BY and WHERE variations. So even with that query there will be 6 or 7 slight variations around the site. I have not got into functions yet but if that is the right way to go I will fixed my attention to understanding them. Steve Quote Link to comment https://forums.phpfreaks.com/topic/224616-duplicating-common-queries/#findComment-1160311 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.