php Phar - mysql connection stays open between pages?

89 Views Asked by At

question for the Phar experts

say I have 3 php files, in each one I open a mysql connecton and do some stuff.

If I squash these 3 pages into one Phar file, does the mysql connection stay open throughout the Phar file?

can I just open it once and leave it open, or do I need to leave it as is with the connection opening at the beginning of each of the 3 files?

1

There are 1 best solutions below

0
On

Not sure what you mean - the lifespan of a resource has nothing to do with how the PHP code is stored retreived. If one of the files is included within another which has opened a connection, the connection will still be available (the second file can only use it if it is in scope or passed as a parameter).

Hence if your phar file implements a daemon, the conection will persiste for the duration of execution. If it is handling web requests, the connection only lasts for the duration of the request.