Jump to content

Using Includes for Queries


dprichard

Recommended Posts

I have two queries that I will be running at the top of each page on my site once the user is logged in to pull in different information about them and to show the company's information.  Would I be better off having these at the top of each page in the code or having them in includes and calling the includes? 

Link to comment
https://forums.phpfreaks.com/topic/56263-using-includes-for-queries/
Share on other sites

If anything is done on many pages, then it is generally better to have them as includes. That way, they can be easily modified if any requirements change. The only thing is you should make sure they are necessary to the file when you include them - otherwise you will be slowing your site down for nothing.

I would recommend creating a functions.php file and putting your queries in a function and just call that function when you need it, so if you are going to use those functions just use the 'include' keyword to have them brought in to your php file.

Firstly, no - there are no performance issues with using includes(to the best of my knowledge) since php processes an include as if the code were there in the file.

 

Second, a function is a quite differant thing to an include - however, often people put functions which will be used throughout their site in one file, which they then include where it is needed.

 

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.