title: Use JS to execute MySQL queries and the security issues it involves
body: <p>I've been searching around the internet for a way to define a query in JavaScript, pass that query to PHP. Let PHP set up a MySQL connection, execute the query and return the results json encoded.</p>
  
  <p>However my concern is with the security of this method since users could tamper with the queries and do things you don't want them to do or request data you do not want them to see.</p>
  
  <h3>Question</h3>
  
  <p>In an application/plugin like this, what kind of security measures would you suggest to prevent users from requesting information I don't want them to?</p>
  
  <h3>Edit</h3>
  
  <p>The end result of my plugin will be something like</p>
  
  <pre><code>var data = Querier({
      table: "mytable",
      columns: {"column1", "column2", "column3"},
      where: "column2='blablabla'",
      limit: "10"
  });
  </code></pre>
  
  <p>I'm going to let that function make an AJAX request and execute a query in PHP using the above data. I would like to know what security risks this throws up and how to prevent them.</p>