title: PHP Function to Create Dynamic SQL Queries
body: <p>I have a lot of repetitive code that inserts and selects data from my MySQL database. Out of curiosity, is it possible to create a PHP function that can take the <code>table</code>, <code>columns</code>, and <code>rows</code> as parameters and generate the SQL statement. A completely dynamic SQL statement generator, if you will.</p>
  
  <p>For example:</p>
  
  <pre><code>function PushData($table, $columns, $values)
  {
      // insert data
  }
  </code></pre>
  
  <p>Furthermore, is the opposite possible. A function that can select and return data.</p>
  
  <pre><code>function PullData($table, $columns, $rowID)
  {
      // grab data
      return data;
  }
  </code></pre>
  
  <p>Is something like this possible? If so, would this be something worth doing?</p>