I have this method for a user
public function isClosed(){
$username = $this->user['username'];
$query = mysqli_query($this->connection, "SELECT user_closed FROM users WHERE username='$username'");
$row['user_closed'] = mysqli_fetch_array($query);
if($row['user_closed'] == "no"){
return false;
}else{
return true;
}
}
and when I want to display the Posts of a user, in the method to display posts I have a while loop that should break if the user_closed column says "yes".
public function loadPostsFriends(){
.
.
$added_by_obj = new User($this->connection, $added_by);
if($added_by_obj->isClosed()){
continue;
}
.
.}
What is happening is that the while loop gets broken like this, although the first method returns that user is not closed (in the database the column user_closed is populated with "no".) This is confusing me, since if in the DB its "no", the if statement says if its "no", return false. The continue function should not be activated, right?
I know this is a newbie question, but I´m new to OOP, thanks for the help.
Aucun commentaire:
Enregistrer un commentaire