Ok so I just found out that I can't use placeholders for table names and columns
$table = 'users';
$stmt = $db->prepare('SELECT * from ?');
$stmt->bindValue(1, $rable, ??);
So what is really an alternative to having dynamic table names?
$stmt = $db->prepare('SELECT * from '.$table);
This would be vulnerable. Is there an escape_string
method for PDO
? I went through the manual but didn't seem to catch one. All I found was quote
but that doesn't work for tables and columns. Is there any way I can securely implement this functionality, or will I have to switch back to using mysqli
?