where to put OPENDB?

I am creating web application with mysql database.

where is the best way to place the opening of the database? is it in the APP or in SESSION?

Both way works, but im still figuring out from the expert, which is the best practice?

Keep the scope as local as possible and close the connection as soon as the database task is complete. This approach will minimize resource utilization and keep database administrators happy.

oh ic.

Thanks!!!

App is completely wrong. Anyplace else is OK.

Hi Tim,

Thanks for enlighten.

[quote=214084:@ronaldo florendo]I am creating web application with mysql database.

where is the best way to place the opening of the database? is it in the APP or in SESSION?

Both way works, but im still figuring out from the expert, which is the best practice?[/quote]

Maybe create a method which handles the opening of the connection and possible errors, which returns a Boolean.
Use this method before you try to access the Database and do your thing.
Close the connection as soon as you collected or sent and veryfied all your data.

Use Transactions to perform multiple Database querries in one step.

And as always, use Prepared Statements where ever possible. :slight_smile:

Thanks!