What is best, I always open the connection with the server, execute a command and close the connection or open once and execute all the commands and close after?
like:
$connection = mysql_connect($host, $user, $password);
mysql_select_db($database, $connection);
mysql_query($sql);
mysql_close($connection);
or:
$connection = mysql_connect($host, $user, $password);
mysql_select_db($database, $connection);
mysql_query($sql);
mysql_query($other_sql);
mysql_query($other2_sql);
mysql_close($connection);
Considered this in a page .php that we can have commands query in whole de page. You think that __construct to open de connection and __destruct to close the connection are a good ideas?