I am using a switch statement on a $_GET variable to produce the result I want on my page.
I am always questioning the best way to run queries in situations like this because I simply do not know the best practice or method. So I have some pseudo code below and I was wondering what the best method would be.
This very well could be a situation where is just doesn't matter in terms of performance, but if it does I want to make sure I do it right.
if(isset($_GET['type'])){
$var = $_GET['type'];
//run the query now and select everything needed from the DB for either switch case.
//view implications that involve pulled data
switch($var){
case '1':
//Or do I run the query here, getting only what I need for this situation
//view implications that involve pulled data
break;
case '2':
//again run the query here, getting only what I need for this situation
//view implications that involve pulled data
break;
}
}
Both cases share one or two similar pieces of data from the DB, but a majority of the content for each case is only needed in that situation.
Bottom line trying to perform the best and keep the code as clean and efficient as possible.
Thanks!