Today in my bootcamp we started constructing and running SQL queries in Node.js. Once we covered the basics my instructor showed us how to use "?" as an escape character, which is supposed to somehow prevent SQL injections. I think I get the gist of this concept, but am very confused as to why one would do this instead of putting whatever variable they're inserting inside a template literal. For example:
db.query("DELETE FROM foo WHERE id = ?", [bar], function (err, result){})
vs.
db.query(`DELETE FROM foo WHERE id = ${bar}`, function (err, result){})
My instructor isn't always the best at uh, instructing, but he's proven to be very knowledgeable so I trust this is for a reason. In the past we've noticed that he often uses older techniques that have been largely replaced by more recent additions to the language; is this maybe a case of him doing that?