CodeIgniter Forums

Full Version: Session Library to Allow Persistent Database Connections for MySQLi
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
So I'm upgrading a client's CodeIgniter based project, and have found a strange behaviour in the newer session class; it throws an exception if the database has persistent connections enabled.

This may be fine as a precaution on some drivers, but for MySQLi persistent connections should be perfectly safe, and they can have a performance benefit, so I'd like to be able to enable them again.

I'd like to propose that database drivers gain a property indicating whether they are persistence safe, so that those that are can indicate such to the session class (and others) to adapt their behaviour accordingly. Either that, or drivers where persistence is potentially unsafe simply shouldn't respect the setting at all, as there seems no point to allowing it if sessions won't work; if someone is implementing their own session handling then a means of forcing persistence could be provided instead.

Of course if there are still any persistence related issues with MySQLi don't hesitate to let me know, but I believe the MySQLi driver handles all necessary cleanup automatically.
Unlike the mysql extension, mysqli does not provide a separate function for opening persistent connections. To open a persistent connection you must prepend p: to the hostname when connecting.