Welcome Guest, Not a member yet? Register   Sign In
Why to ALWAYS create a new DB connection (MySQL case)?
#1

[eluser]kadishmal[/eluser]
I don't know what is the statistics of how many users use persistent connection in CI or how many use non-persistent dbconnect(), but I wonder why would user want to create a NEW connection every time dbconnect() is called?

The dbconnect() function has the following code:

Code:
public function db_connect()
{
return @mysql_connect($this->hostname, $this->username, $this->password, TRUE);
}

TRUE parameter at the end forces the database driver to establish a new connection even if the parameters are the same with already opened connection.

I can think of one situation when a user would actually want to establish a new connection. It is when user wants to execute certain operations in parallel using asynchronous queries. Other than that.... user would probably want to reuse the open connection.

I tried to look the entire history of changes for mysql_driver.php file, but didn't have patience further than the 3rd page. Would anyone please explain me the background of "forcing a new connection"?

The reason I am asking is because I am updating the CUBRID Database driver for CI and I wonder why there is such a code.

Thank you in advance.


Messages In This Thread
Why to ALWAYS create a new DB connection (MySQL case)? - by El Forum - 02-12-2012, 11:47 PM
Why to ALWAYS create a new DB connection (MySQL case)? - by El Forum - 02-13-2012, 12:01 AM
Why to ALWAYS create a new DB connection (MySQL case)? - by El Forum - 02-13-2012, 01:29 AM



Theme © iAndrew 2016 - Forum software by © MyBB