title: Call to a member function query() on string OOP PHP
body: <p>I'm new to OOP PHP so im trying to learn by doing a few basic things, the error im getting is in the title the query just keeps returning that error.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?php 
  
  //CONNECTION STARTS HERE
  class connection{
  
   private $host = 'localhost';
   private $username = 'root';
   private $password = '';
   private $database = 'test';
   public $conn;
  
   public function __construct(){
  
    return $this-&gt;conn = mysqli_connect($this-&gt;host, $this-&gt;username, $this-&gt;password, $this-&gt;database) or die("MySQL Error");
  
   }
  
  }
  
  //USERS STARTS HERE
  class users{
  
   public $db;
  
   public function __construct($db){
  
    $this-&gt;db = $db;
  
   }
  
   public function getAllUsernames($db){
  
    $query = "SELECT * FROM users";
  
          //ERROR IS ON THIS LINE
    $all_users = $this-&gt;db-&gt;query("$query");
  
    while ($row = $all_users-&gt;fetch_assoc()) {
     return $row['username'];
    }
  
   }
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>I have no idea where im going wrong can someone help me get a better understanding of what ive done wrong, I know that I have to clean up a lot of the previous code but as I said im learning and that's another story for now I just want to know what this error means and what's making it..?</p>