When I wrote PHP code with PDO and MySQL, I always created connections when I needed it, as part of such functions:
result pseudo_function() {
create and open connection
do stuff
close connection
return result
}
Now I started programming in C, I saw that pointers are an interesting way to pass an entire connection as a parameter to a function. I was wondering if it would be better to pass connections between functions until the entire user request has been submitted.
To clarify: for a single user request there can be 1-5 calls to a function that then opens the database, retrieves data, does something, closes and returns.
Does performance difference also matter if you support an open connection?
source
share