Prepared statements. Should I use prepared php statements even in requests without (?) Placeholders?
It makes sense for me to use ready-made instructions in a request of the following type:
$sqlQuery = "SELECT phone FROM contact WHERE name = ? ";
However, in the following situation, it makes sense and is it useful to use prepared statements, as is sometimes seen?
$sqlQuery = "SELECT name FROM contact";
Thank you in advance
+3
source to share
2 answers
Typically, only prepared statements are needed to be used with user input. This is great for use in situations where user input is also not affected. If you are using PDO, you may be more comfortable using the same PDO connection string and query process as before, as using a different set of functions will require you to reopen the connection.
+2
source to share