PHP Patterns - how can I write this code?
<p>I want to make an category-system CMS. Everything is fine, except a big trouble.</p>

<p>How can I can handle and generate the mysql query depends by some inputs like:</p>

<blockquote>
  <p>site.com/some-category&amp;sortby=views&amp;from=smt&amp;anotherInput=key</p>
</blockquote>

<p>For example, for this input my query should be something like</p>

<pre><code>SELECT * FROM `articles` WHERE from='smt' AND afield='key' ORDER BY VIEWS
</code></pre>

<p>But these inputs will be different. How I can write this code? I don't know much things about designs patterns, but, I've heard about Factory pattern, is this a part of my solution? </p>

<p>Than </p>
