I'm using the PDO class to connect to mysql becuase I noticed that it's the best and surest way to do it. I noticed also that i can't use PDO parameter in tables name so I saw this question: Can PHP PDO Statements accept the table or column name as parameter?
I use in my application a GET parameter as a table name and now my question is: It's better to use
function buildQuery( $get_var )
{
switch($get_var)
{
case 1:
$tbl = 'users';
break;
}
$sql = "SELECT * FROM $tbl";
}
or just give a "show tables" in MySql and compare every single table resulted from this command to the table passed via GET?
Thank you all!