When executing functions in the same script:
Should I open a new connection in each function, or should I pass the last connection variable as a parameter?
Is passing the connection variable as a parameter a good practice?
When executing functions in the same script:
Should I open a new connection in each function, or should I pass the last connection variable as a parameter?
Is passing the connection variable as a parameter a good practice?
If you have several functions using the same PDO connection instance, you should pass this variable to your functions instead of instanciating an new object for each function this way you will have less overhead.