Why do I get a result using this code
$stmt = $users_db->prepare('SELECT * FROM users WHERE user_name = :value');
$stmt->execute([':value' => 'someUser']);
$res = $stmt->fetch();
but not this code?
$stmt = $users_db->prepare('SELECT * FROM users WHERE :field = :value');
$stmt->execute([':field' => 'user_name', ':value' => 'someUser']);
$res = $stmt->fetch();
I know I can work around this by using e.g. 'SELECT * FROM users WHERE ' . $field . ' = :value'
, but I'd like to know the reason behind not being able to do this. (The reason I need this is because I'm checking if a username or email already exists in the database, hence the need for the variable column name).