I need to connect with database and don't need to show errors. i must use try/catch exception.
class MySqlDatabase {
private $connection;
function __construct() {
$this->open_connection();
}
public function open_connection() {
$this->connection = mysql_connect(HOST_NAME, DB_USER, DB_PASSWORD);
if (!$this->connection) {
die('Not connected: ' . mysql_error());
} else {
$db_selected = mysql_select_db(DB_NAME, $this->connection);
if (!$db_selected) {
die ('Can\'t use foo : ' . mysql_error());
}
}
}
public function getConnection() {
return $this->connection;
}
}