Forum Moderators: coopster

Message Too Old, No Replies

Basic PHP & MySQL coding help

         

impact

3:07 am on May 9, 2011 (gmt 0)

10+ Year Member



Hello,

I need help on coding.

Lets assume I have two distinctive Class A and Class B doing two different jobs in the same database.

In class A, function A1, i create database connection, do some query work and then, initialize class B to call function B1. Database connection is created in function B1. Does query work from the database, database connection is closed and returns data. This data from function B1 of class B, is used for calculation in function A1 of class A and then, it is saved in the database. I close database connection in function A1 of class A.

Here is my question. Inside function A1 of Class A, i am creating database connection and then calling function B1 of class B. In a situation like this, do I really need to create another database connection with in function B1 of class B and close the database connection, before returning data?

or

database connection inside function A1 of class A, is just enough?

Thank you

caz338

7:22 am on May 9, 2011 (gmt 0)

10+ Year Member



You could just create and include a separate class for the database, then make sure you connect to the database and stay connected till your done.