We were unable to load Disqus. If you are a moderator please see our troubleshooting guide.

Marchete • 5 years ago

I find interesting the playground, but I'd like to know if it's possible to have some examples with named parameters instead of positional parameters (like :userid instead ? in the queries).
Positional parameters are OK for small queries, but having worked with 250+ lines SQL queries I find a bit complex to keep track of what is each positional parameter.

Also if you ever changes the order of the where filters you break the query:
"select u.name, t.team_id from user u left outer join team t on u.team_id=t.team_id WHERE u.user_id=? AND u.name LIKE ?" OK
"select u.name, t.team_id from user u left outer join team t on u.team_id=t.team_id WHERE u.user_id=:user_id AND u.name LIKE :name"

If you change the order of the clauses in WHERE you break the first (as parameters will mix up), but the latter will remain OK.
Also if you need to use the same parameter N times (subqueries, etc), named parameters simplify that.