I would like to know, when I should use these types of conditions, I already did the test returns the same thing to me, but what's the difference? I believe it is not only diminish lines, but we will combine the second option is cleaner right?
public function method($param) {
$sql = "SELECT * FROM 'table' WHERE field = :field";
$count = $this->_db->select($sql, array('method' => $param[1]));
if ($count->rowCount() > 0) {
return true;
} else {
return false;
}
}
Here is the second with ternary condition.
public function method($param) {
$sql = "SELECT * FROM 'table' WHERE field = :field";
$count = $this->_db->select($sql, array('method' => $param[1]));
return $count->rowCount() > 0 ? true : false;
}
What promotes difference in my code?