title: PDO results showing results of previous query, how to display current results?
body: <p>I have two queries however the pdo->results are showing the original results and not the next results. I want results query_1 = (a1, a2, a3) and then query_2 = (b1, b2, b3). But the results are showing a1, a2, a3 and then a1, a2, a3 again. </p>
  
  <p>DbGlobal.php:</p>
  
  <pre><code>class DbGlobal 
  {
    private static $_instance = null;
  
    private $_pdo,
        $_query,
        $_error = false,
        $_results,
        $_count = 0;
  
    private function __construct()
    {
      try 
      {
          $this-&gt;_pdo = new PDO('mysql:host='. ConfigGlobal::get('mysql/host') .';dbname='. ConfigGlobal::get('mysql/db'), ConfigGlobal::get('mysql/username'), ConfigGlobal::get('mysql/password'));
          //$this-&gt;_pdo-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
      } 
      catch (PDOException $e) 
      {
          die($e-&gt;getMessage());
      }
    }
  
    public static function getInstance()
    {
      if(!isset(self::$_instance)) 
      {
          self::$_instance = new DbGlobal();
      }
      return self::$_instance;
    }
  
    public function query($sql, $params = array())
    {
      $this-&gt;_error = false;
  
      if($this-&gt;_query = $this-&gt;_pdo-&gt;prepare($sql)) 
      {
        $x = 1;
        if(count($params)) 
        {
          foreach($params as $param) 
          {
            $this-&gt;_query-&gt;bindValue($x, $param);
            $x++;
          }
        }
        if($this-&gt;_query-&gt;execute()) 
        {
          $this-&gt;_results = $this-&gt;_query-&gt;fetchAll(PDO::FETCH_OBJ);
          $this-&gt;_count = $this-&gt;_query-&gt;rowCount();
        } 
        else 
        {
          $this-&gt;_error = true;
        }
      }
      return $this;
    }
  }
  </code></pre>
  
  <p>QueryPage_1.php</p>
  
  <pre><code>$varname = 'Settings_SideBarButtons';
  $vararray = array("UniqueId,", "Url,", "Dirr,");
  $varstring = implode($vararray);
  ${$varname} = DbGlobal::getInstance()-&gt;query("SELECT ".$varstring." FROM 
  ".$varname." WHERE a='1'");
  </code></pre>
  
  <p>In database:</p>
  
  <pre><code>UniqueId =&gt; a1
  Url =&gt; a2
  Dirr =&gt; a3
  </code></pre>
  
  <p>Results are correct:</p>
  
  <pre><code>print_r($Settings_SideBarButtons-&gt;results());
  //output:
  Array 
  ( [0] =&gt; stdClass Object 
      ( [UniqueId] =&gt; a1 
        [Url] =&gt; a2 
        [Dirr] =&gt; a3
      ) 
  ) 
  </code></pre>
  
  <p>And then I have in the same query script with another query that has a different varname.</p>
  
  <p>QueryPage_2.php</p>
  
  <pre><code>$varname = 'Core_Settings';
  $vararray = array("UniqueId,", "Url,", "Dirr,");
  $varstring = implode($vararray);
  ${$varname} = DbGlobal::getInstance()-&gt;query("SELECT ".$varstring." FROM 
  ".$varname." WHERE a='1'");
  </code></pre>
  
  <p>In database:</p>
  
  <pre><code>UniqueId =&gt; b1
  Url =&gt; b2
  Dirr =&gt; b3
  </code></pre>
  
  <p>But the Results are:</p>
  
  <pre><code>print_r($Core_Settings-&gt;results());
  //output:
  Array 
  ( [0] =&gt; stdClass Object 
      ( [UniqueId] =&gt; a1 
        [Url] =&gt; a2 
        [Dirr] =&gt; a3
      ) 
  ) 
  </code></pre>
  
  <p>I have confirmed that the results displayed in the second query are the results from the first query.<br>
  Am I using PDO object incorrectly? Do I have to PDO->freeresult(); somehow?</p>