when MySQL dba_close($dba)
Posted: Sun May 30, 2010 12:29 pm
Hello all,
I have just begun php programming and I have a question about when to close a database link. I have searched on google, I have a book "Teach Yourself PHP in 24 Hours" gives some solid examples, W3C school.org also but I cannot seem to find a defined usage of closing the connection. The examples I have examined instruct you to close a link so that other connections can interact with the database, it is not multi-threaded which is causing me some confusion.
Perhaps I should tell you what I am doing. I am working on developing a rather large project which is OOD(object oriented design)/OOP(object oriented programming) and I am breaking up functionality classes into objects such as:
config.php - stores the connection variables
openlink.php -opens the connection to the database -
dbconnect.php - creates the database if one is not created yet, and connects to it -
createtables.php - creates the necessary tables if they are not already created -
query.php - populates the tables with the primary keys. -
So far these are the only classes that i have. And my question is would I execute the AFTER all this is created?
As far as the design pattern I have, I would like all scripts that interact with the database except the openlink.php to fire only once using the include_once() I forget exactly that method.
Should I close the connection after creating the tables for other classes to be called to interact with the MySQL database?
I have just begun php programming and I have a question about when to close a database link. I have searched on google, I have a book "Teach Yourself PHP in 24 Hours" gives some solid examples, W3C school.org also but I cannot seem to find a defined usage of closing the connection. The examples I have examined instruct you to close a link so that other connections can interact with the database, it is not multi-threaded which is causing me some confusion.
Perhaps I should tell you what I am doing. I am working on developing a rather large project which is OOD(object oriented design)/OOP(object oriented programming) and I am breaking up functionality classes into objects such as:
config.php - stores the connection variables
openlink.php -opens the connection to the database -
Code: Select all
include('config.php');Code: Select all
include('openlink.php');Code: Select all
include('dbconnect.php');Code: Select all
include('createtables.php');Code: Select all
dba_close($myconnection);As far as the design pattern I have, I would like all scripts that interact with the database except the openlink.php to fire only once using the include_once() I forget exactly that method.
Should I close the connection after creating the tables for other classes to be called to interact with the MySQL database?