title: Appending new data to object
body: <p>I'm stuck trying to append new data to an stdClass object that I'm creating for an AMchart</p>
  
  <p>I'm returning all the rows I want from the DB, then creating a new object and looping through the returned array, but rather than appending what I want to the end of the existing object, it just gets overwritten. PHP objects dont have an append or push method, so how do you accomplish this? </p>
  
  <p>Here's what my code looks like. Am I missing something simple?</p>
  
  <pre><code>    $sql = 'SELECT 
              count(*) as clients,
              STR_TO_DATE(Appt_date, \'%m/%d/%Y\') AS date,
              SUM(wait_time) as total_wait_time
              FROM tb_by_client
              WHERE status = @qualifier
              GROUP BY Appt_date';
  
      $rows = $db-&gt;fetchAll($sql);
      $chartObject = new stdClass();
      foreach($rows as $row){
          $row-&gt;average = round($row-&gt;total_wait_time / $row-&gt;clients);
          $chartObject-&gt;date = $row-&gt;date;
          $chartObject-&gt;average = $row-&gt;average;
      }
      $chartArray[] = $chartObject;
      return json_encode($chartArray);
  </code></pre>
  
  <p>So instead of getting something that looks like this</p>
  
  <pre><code>[{"date":"2018-10-01","average":12},{"date":"2018-10-02","average":-33},{"date":"2018-10-04","average":23},{"date":"2018-10-05","average":6}]
  </code></pre>
  
  <p>I get back just a single</p>
  
  <pre><code>[{"date":"2018-10-01","average":12}]
  </code></pre>
  
  <p>Because each loop overwrites the last key and value</p>
  
  <p>How do you append instead?</p>