I am creating a class function that connects to a mySQL server and then selects a database. There are two approaches to creating a segment of this code.
1st approach
Code:
if ( !($this->connection =@ mysql_connect($sqlhost, $sqluser, $sqlpw)) ) {
return false;
}
if ( mysql_select_db($sqldb, $this->connection) ) {
return true;
} else {
return false;
}
2nd approach
Code:
$this->connection =@ mysql_connect($sqlhost, $sqluser, $sqlpw) || return false;
mysql_select_db($sqldb, $this->connection) || return false;
return true;
Which is the better choice and why?