Let\'s say I want to select records where Id = 30
. Prepared statements allow two ways of binding parameters:
question marks
This seesm to be more of a preference based question as there isn't a strict right or wrong answer.
Personally I avoid ?
as it's tightly tied to the order of parameters. Although theoretically you shouldn't be able to mess this up by adding or removing binding a single binding, it just seems like it's asking for trouble. It is (slightly) less work though.
:name
is more concise and is tightly bound to the identification of bindings, not arbitrarily to the order. It involves a (tiny) bit more work but it is much easier to debug, and less prone to mistakes.
I prefer being (slightly) concise over writing (slightly) less code.