Example:
class SimpleClass{ public function foo() { mysql_open(); //do mysql query here mysql_close(); } public function boo() { mysql_open(); //do mysql query here mysql_close(); } } Or is it better to have one mysql_open in the beginning of the class and one in the end?
Thanks.
EDIT: I use mysqli, this is just an example. Should I open and close in each page file instead? Like in index.php, cataegory.php should have one open and close each.
mysql_*functions in new code. They are no longer maintained and are officially deprecated. See the red box? Learn about prepared statements instead, and use PDO or MySQLi - this article will help you decide which. If you choose PDO, here is a good tutorial.