title: How do you manage SQL Queries
body: <p>At the moment my code (PHP) has too many SQL queries in it. eg...</p>
  
  <pre><code>// not a real example, but you get the idea...
  $results = $db-&gt;GetResults("SELECT * FROM sometable WHERE iUser=$userid");
  if ($results) {
      // Do something
  }
  </code></pre>
  
  <p>I am looking into using stored procedures to reduce this and make things a little more robust, but I have some concerns..</p>
  
  <p>I have hundreds of different queries in use around the web site, and many of them are quite similar. How should I manage all these queries when they are removed from their context (the code that uses the results) and placed in a stored procedure on the database?</p>