Jump to content

SQL database access question


Dekieon

Recommended Posts

I'm am fairly new to PHP, and it seems to be going good so far, but I have a question about accessing the SQL server.

 

 

 

the way I have designed the site is by having the index.php being the page that is always getting rendered, and all other php files are called from the index.php. Many of the php files that get included need acsess to the SQL database.

 

Would it be better to ....

 

1. open access to the SQL database at the beginning of the index.php file, and then close it again at the end of the index.php file. This would give all my php scripts access to the database without having to establish a connection to the database over and over again.

 

or

 

2. Open access to the sql database only when i need information from it and then close it again right afterwards. This would cause me to open  and close access to the database multiple times during page rendering.

 

 

I am interested in page rendering speed, which option is faster? I am guessing that option 1 woud be faster.

I am interested in security, which option keeps the SQL data more secure? I am guessing option 2 would be more secure.

 

What is everyones opinion?

 

 

Link to comment
https://forums.phpfreaks.com/topic/43823-sql-database-access-question/
Share on other sites

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.