Answer the question
In order to leave comments, you need to log in
Mysql_connect and mysql_pconnect question
Actually, I know that this is a stupid question,
but do I understand correctly that when using mysql_connect, until the end of the script, all requests go through this connection, and for each request there is no new connection or reconnect, and the connection is closed only after the script dies or mysql_close?
Or all the same, a new connection is created for each request, and whatever it is, you need to use mysql_pconnect (or its taxes in mysqli, pdo)?
Answer the question
In order to leave comments, you need to log in
all requests inside one script go through one connection anyway ... you establish it by calling mysql_connect
difference mysql_connect after completion the script will close the connection ... and after mysql_pconnect the connection will remain hanging ...
when the script is restarted, mysql_connect will again open a new connection ... and mysql_pconnect will connect to an already open one
I’ll add on my own, if you don’t know - use mysql_pconnect ... sometimes it gives a significant gain ...
for more details, no matter how trite it sounds, in the official documentation www.php.net/manual/ru/features.persistent-connections.php
about mysql_pconnect php.net/manual /en/function.mysql-pconnect.php“Firstly, when connecting, the function tries to find an already open (permanent) pointer to the same server with the same user and password. If it is found, it will be returned by the function instead of opening a new connection.
Secondly, the connection to the SQL server will not be closed when the script ends. Instead, it will remain operational for future use ( mysql_close() also does not close persistent connections opened by mysql_pconnect())."
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question