Singleton mode creates mysql connections, how to write if there are multiple mysql instance machines

1. The commonly used mysql singleton class can work when there is only a single mysql machine, but when there are multiple mysql machines, you need to create connections between multiple machines, but you still want to create only one connection for one mysql instance during a request. In this case, how to encode the singleton class

Php
Jun.15,2021

if(!isset($dbInstances[$dsn]))
{
    $dbInstances[$dsn] = new db;
}
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e60d60-458e7.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e60d60-458e7.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?