title: Store variables from MySQL select to PHP class variables more efficiently when the table field names are identical to the class variable names?
body: <p>I am selecting data from a database.  The database field names are exactly the same as the class variable names.  Is there a way to store this data into the class variables without specifying each one individually?</p>
  
  <pre><code>    //gets info about a specified file.
      //chosen based on a supplied $fileId
      function getFileInfo($fileId)
      {
          //select info from database
          $sql = "SELECT id, companyId, url, name, contentType, fileSize, saved, retrieved
                  FROM files
                  WHERE id = $fileId";
          $results = $this-&gt;mysqli-&gt;query($sql);
          $results = $results-&gt;fetch_object();
  
          //store info into class variables
          $this-&gt;id = $results-&gt;id;
          $this-&gt;companyId = $results-&gt;companyId;
          $this-&gt;url = $results-&gt;url;
          $this-&gt;name = $results-&gt;name;
          $this-&gt;contentType = $results-&gt;contentType;
          $this-&gt;fileSize = $results-&gt;fileSize;
          $this-&gt;saved = $results-&gt;saved;
          $this-&gt;retrieved = $results-&gt;retrieved;
      }
  </code></pre>