here we got a positional parameter:
SELECT
u
FROM ForumUser u
WHERE u.id = ?1
and here a named parameter:
SELECT
u
FROM ForumUser u
WHERE u.username = :name
this is DQL (doctrine query language) but i think the concept is the same.
could someone please explain what these mean and do?
A positional parameter is set by its index in the clause.
A named parameter is set by its name.
When you are setting the values, you might have the values in an array, in which case the positional form could me more useful. Alternatively, you might have them in an associative array by name, in which case the named form is more useful.
Update – Although the documentation refers to positional parameters as for example
?1, the examples just use?.This example of positional parameters maps values by position in the array provided into the positional placeholders in the query.
However this example maps values by name in an associative array to their named placeholders. See how they do not need tgo be in order.
(Have to admit I’m not a PHP guy – above based on the examples here.)