문제

Just wondering what peoples opinions are about defining values inside SQL statements when using the prepared statements such as:

$sql->query("SELECT * FROM ".TABLE_NAME." WHERE id = :id");
$sql->bind(':id', $id);

Not all the code but you can see what I am getting at. Should I bind the table name is what I am basically asking.

도움이 되었습니까?

해결책

You can't use prepared statements for table and column names.
I advise you to use prepared statements everywhere since it is resilient against SQL injection (you don't have to care about escaping your values).
They also provide a performance benefits if you run them more than once.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top