Jump to content

Duplicating common queries


MargateSteve

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/224616-duplicating-common-queries/
Share on other sites

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.