All,
I don't really understand the usage case for named placeholders bindParam(':blabla', $blabla)
versus numbered placeholders bindParam(1, $blabla)
. Is it mostly a question of readability?
Thanks,
JDelage
All,
I don't really understand the usage case for named placeholders bindParam(':blabla', $blabla)
versus numbered placeholders bindParam(1, $blabla)
. Is it mostly a question of readability?
Thanks,
JDelage
It's mostly just a readability thing. Personally, I would used named placeholders when possible. I would generally use numbered placeholders only if I was building a dynamic query where you don't know exactly what or how many parameters there will be until runtime.
Simple Answers:
numbered placeholders will prove to be a PITA when you want to expand your query by adding an additional placeholder in the middle, requiring you to renumber everywhere you use placeholders after the placeholder you just inserted.
Named placeholders, on the other hand, won't have this problem, as the position of the placeholder does not matter for the binding of the placeholder.