According to PHP Documentation PDO :: prepare () appends quotes to all of your parameters, so you don't need to worry about this:
"Parameters for prepared statements do not have to be specified, the driver automatically processes this. If the application uses exclusively prepared statements, the developer can be sure that SQL injection will not happen (however, if other parts of the query are built with unrelated input, SQL injection will still possible). "
The problem with this for me is how I build my queries and database structure. Typically, the FROM part of an SQL statement need not be parameterized because the table is likely to be determined by direct user input. However, with my code, which takes place in some places, and thus, I feel more comfortable with the parameterized version.
SELECT * FROM ? WHERE ?=?
unlike SELECT * FROM tablename WHERE? =?
So my question is, is it possible to prevent my PDO from adding quotes around the FROM parameter so that I don't get SQL errors thrown into my face? Or should I do it differently.
hamalnamal
source share