There is no overloading in PHP; you cannot have methods with the same names but different parameters
Since all of your properties will default to null, there's no reason to do it yourself. I would suggest doing the following:
public function __construct($nick = null) {
if ($nick != null) {
$query = "SELECT * FROM Users WHERE nick='".$nick."'";
$result = App::runQuery($query);
$user = $result->fetch_object();
$this->id = $user->id;
$this->nick = $user->nick;
$this->email = $user->email;
$this->password = $user->password;
$this->birthDay = $user->birthDay;
$this->sex = $user->sex;
$this->about = $user->about;
$this->city = $user->city;
$this->photo = $user->photo;
$this->following = $user->following;
$this->followers = $user->followers;
$this->statu = $user->statu;
}
}
An alternative to the above code is to have multiple, static constructor methods, and use a private constructor:
private function __construct() {
}
public static function createFromNick($nick) {
$self = new self();
$query = "SELECT * FROM Users WHERE nick='".$nick."'";
$result = App::runQuery($query);
$user = $result->fetch_object();
$self->id = $user->id;
$self->nick = $user->nick;
$self->email = $user->email;
$self->password = $user->password;
$self->birthDay = $user->birthDay;
$self->sex = $user->sex;
$self->about = $user->about;
$self->city = $user->city;
$self->photo = $user->photo;
$self->following = $user->following;
$self->followers = $user->followers;
$self->statu = $user->statu;
return $self;
}
public static function createEmpty() {
return new self();
}