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.
$q = Doctrine_Query::create()
->from('User u')
->where('u.username = ? and u.age = ?', array('Arnold', 50));
$users = $q->fetchArray();
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.
$q = Doctrine_Query::create()
->from('User u')
->where('u.username = :username and u.age = :age',
array(':age' => 50, ':username' => 'Arnold'));
(Have to admit I'm not a PHP guy - above based on the examples here.)