Is it possible pass a column name as parameter in a prepared MySQL statement? Take the following example:
UPDATE Images
SET :placement = :imageURL
WHERE ID = :titleID;
PDO adds '
around each parameter, so the middle line above becomes:
SET 'Homepage' = '1.jpg'
Which MySQL doesn't like. Is there a way to include parameters for fieldnames in PDO statements and have them accepted?
Otherwise I guess I'll have to write several different PDO statements, depending on what's been chosen(?).
In situations such as this, I use a different sort of replacement parameters, like so:
The prepared SQL query ends up being processed (more or less) as:
Which works for my situation. I hope this helps. :)
You would need to do something like this:
Parameterized placeholders are only for values.
I would suggest you read the comment @YourCommonSense posted on your question.