random1 Posted December 23, 2007 Share Posted December 23, 2007 I have a query that I use: select VERSION() AS 'MySQL Version', DATABASE() as 'Database Name', USER() as 'Username & Host', CONNECTION_ID() as 'Connection ID' It gets some info about MySQL. On my site I have used a PHP singleton (one one database connection per user) database class to manage connections. But the above query returns a new "Connection ID" each time the page loads (increments of 1). Is this expected or does this mean that the singleton connection class is not working? ??? Quote Link to comment https://forums.phpfreaks.com/topic/82966-singleton-connection-to-database/ Share on other sites More sharing options...
fenway Posted December 23, 2007 Share Posted December 23, 2007 I would guess the latter, but I've no experience with persistent connections. Quote Link to comment https://forums.phpfreaks.com/topic/82966-singleton-connection-to-database/#findComment-421999 Share on other sites More sharing options...
trq Posted December 23, 2007 Share Posted December 23, 2007 But the above query returns a new "Connection ID" each time the page loads (increments of 1). As expected. A singleton will not persist accross multiple requests. Quote Link to comment https://forums.phpfreaks.com/topic/82966-singleton-connection-to-database/#findComment-422004 Share on other sites More sharing options...
random1 Posted December 23, 2007 Author Share Posted December 23, 2007 Thanks, Just really wanted to make sure that it was working right. I just ran the same query 3 times on the same page and it had the same ID each time Quote Link to comment https://forums.phpfreaks.com/topic/82966-singleton-connection-to-database/#findComment-422027 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.