Welcome Guest, Not a member yet? Register   Sign In
Session Library to Allow Persistent Database Connections for MySQLi
#1

(This post was last modified: 06-28-2018, 08:25 AM by Haravikk.)

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.
Reply
#2

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.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB