views:

50

answers:

2

Hi All,

Just a quick question here:

If I choose the object oriented style to interact with my database, ie...

$mysqli = new mysqli("localhost", "my_user", "my_password", "world");

And I then use $mysqli->close(); to close the connection at some point...

Can I reopen that connection by simply initiating another query $mysqli->query();, or do I have to instantiate a new MYSQLI object?

A: 

No, you have to instantiate a new MYSQLI object. You can use the same variable $mysqli though but you have to write this code again:

 $mysqli = new mysqli("localhost", "my_user", "my_password", "world");
shamittomar
A: 

You could simply not close the mysqli connection and reuse it.

Michael Robinson