Reconnecting on MySQL Server Has Gone Away
问题 How can I modify this class to catch exception where MySQL Server Goes Away, and reconnect? <?php class DBConn { private $conn; public function __construct( $persistent = false ) { try { $this->conn = new PDO( "mysql:host=localhost;dbname=test", 'test', "hoollaahaoo" ); $this->conn->exec( "SET CHARACTER SET utf8" ); $this->conn->setAttribute( PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC ); if ( $persistent ) $this->conn->setAttribute( PDO::ATTR_PERSISTENT, true ); } catch( PDOException $e )