I have two PHP classes. One is for connecting to the database, building queries, executing them, and disconnecting from the database. The other class is for users: adding th
In PHP, the best practice is to take the global approach. This is mainly due to the fact that repeated connects/disconnects to the MySQL server can cause a significant decrease in performance.
In fact, though this may seem counter-intuitive, most PHP experts (including myself) recommend that you avoid using mysql_close() altogether, unless there's a pressing reason not to. This is because that is handled automatically in PHP's cleanup anyway, so adding mysql_close() just creates a further deterioration in performance.