i have methods in a php class which returns boolean response the code i have used is.
public function checkIfExist($table ,$key, $value)
{
$sth = $this->dbh->prepare("SELECT COUNT(*) FROM $table WHERE $key = :value");
$sth->bindParam(':value', $value);
$sth->execute();
if($sth->fetchColumn() >= 1)
{
return true;
}
return false;
}
the above method works for me without the else condition being included, logically it should work because once the functions get the true as boolean response it will exit the method. but is it the right way or should i be including else condition there?
return $sth->fetchColumn() >= 1;that's how I like em.