Wednesday, 14 August 2013

Where does codeigniter create and destroy mysql connection and is the db class singleton?

Where does codeigniter create and destroy mysql connection and is the db
class singleton?

If we have multiple database groups in database.php:-
1) Do the connections of all of them are made even only one has to be used
in a particular call. ie. if i have database groups a,b And in my call i
load model that is loading only group b.
2) If i have loaded two models in my controller and if both of them are
loading same databases, would different connection will be made or same
connection will be shared.
Ex:- controller mycont.php has following:-
$this->load->model('model1');
$this->load->model('model2');
If both model1.php and model2.php has following:-
$this->load->db('connection_name');
3) Where are the connections closed.
Ex:- If i have following code:-
$this->databaseFunc();//completes the database work nothing required after
this here a curl call is made which takes long time
So when does database connection is closed, after curl or it gets closed
itself on over exceeding mysql_wait_time configuration at mysql server.
Hope the answer to this question will prove useful for understanding DB
with codeigniter in a better way.

No comments:

Post a Comment