Help nubasu. There is a site in which online +30 people. These 30 people actively interact with 3 databases. One local, others - no (the rights only to select).

Does it make sense to make a permanent connection to bases that are not located locally? I am very annoying:

There are two additional warnings to keep in mind when working with persistent connections. In case the script locks the table and for some reason cannot release it, using a persistent connection, all subsequent scripts that use this connection will be blocked indefinitely and may require restarting the web server or database server. The second caveat is that open transactions, if they were not closed before the script is completed, will be continued in the next script that uses the same persistent connection. Based on this, you can use the register_shutdown_function () function to specify a simple function that unlocks tables or rolls back your transactions. It is even better to avoid these problems completely, without using persistent connections in scripts that use table locks or transactions (you can still use them somewhere else).

try { $this->db = new PDO($config['adapter'] . ':host=' . $config['hostname'] . ';port='.$config['port'].';dbname=' . $config['dbname'], $config['username'], $config['password'], array(PDO::ATTR_PERSISTENT => true)); } catch (PDOException $e) { echo $e->getMessage(); } 

    1 answer 1

    Since remotely you have only SELECT, you can not be afraid of locks.

    But if it is possible to use the API (or write), that is, it is better to request data not in the database directly, but with the help of a script running on a remote server.

    You do not leave the server - for quite a long time, mysql is resistant to connection disruption. But how slow will it all work ....