in this course they build a class with a function of connect like this
private function connect(){
$this->connection = new mysqli($this->host, $this->username, $this->password, $this->db_name);
if(!$this->connection){
$this->error = "Connection Failed: ".$this->connection->connect_error;
return false;
}
And they build the function select like this
public function select($query){
$result = $this->connection->query($query) or die();
}
I have never seen such construct with $this->...->.... Furthermore, the if-error in function one doesn't work an I gave replaced it with
if(mysqli_connect_errno()) {echo("Connection failed: " . mysqli_connect_error());}
and it works fine.
What is the correct way. Thank you