title: Pass dynamic arguments to an object-> on sql fetch using PHP
body: <p>I want to make a dynamic list of arguments for my sql fetch, since the sql might vary a lot.</p>
  
  <p>The list represent the database col names:</p>
  
  <pre><code>$args = array(
      'id',
       'colname',
       'colname2',
       'colname3',
       'colname4'
  );
  </code></pre>
  
  <p>Function will fetch all the data, and add the values to an array to be later stored in memcache.</p>
  
  <pre><code>$fetch = $db-&gt;connect-&gt;query('select * from tablename');
  $result = array();
  if ($fetch) {
  
      while ($obj = $fetch-&gt;fetch_object()) { 
  
          $params = array();
          for($x=0;$x&lt;count($args);$x++){
              $params[] = $obj-&gt;$args[$x];
          }
  
          $result[$obj-&gt;id] = $params;
      }
  }
  </code></pre>
  
  <p>Gives me this error: Notice: Array to string conversion in...</p>