In PHP/MySQL should I open multiple database connections or share 1?

前端 未结 6 779
北恋
北恋 2021-01-17 15:50

I am wanting to hear what others think about this? Currently, I make a mysql database connection inside of a header type file that is then included in the top of every page

6条回答
  •  北海茫月
    2021-01-17 16:18

    In PHP+MySQL usually there is no much sence to use multiple connections per page (just slower and a little more RAM consumed).

    The only way it might be useful is when you alter connection paremters which might interfer with other pages (like collation). But good PHP programs usually never do that kind of stuff.

    Also, it is a good idea to enable persistent connections, so that 1 MySQL connection would be reused across multiples page executions.

提交回复
热议问题