title: What Is Less Server Strain: PHP IF Statements or SQL SELECT ALL, Filter Client Side
body: <p>I am building a Web Application, that will query a lot of data, with the emphasis being on the user to customise their query down to the nth degree.</p>
  
  <p>As an example I have built a form, where the user can define anywhere between 0 - 50 criteria, each tied to a specific database value. if they define nothing they get all, and so on.</p>
  
  <p>I then allow the user to define once they define the criteria what columns they would like to see, this too allows anywhere from 1 - 50 columns. default around 5 - 10.</p>
  
  <p>I am trying to keep as much of the app client side as possible, limiting the server side strain. But what is less effort on the server;</p>
  
  <p>PHP If statement around every column, if the user doesnt want it, then dont POST it as part of SQL Statement. i.e. Check if user wants it and filter SELECT statement.</p>
  
  <p>Or</p>
  
  <p>Have the SQL Statement rigid, and return all columns, and filter once returned client side.</p>
  
  <p>I know it might side cut and dry, but the way i see it, 50 PHP IF statements, is a lot to check? but returning all Rows and all Columns is also quite a large ask?</p>
  
  <p>Any help would be appreciated.</p>