Fixed the replacement of query parameters

when using positional paramaters, substr will return false as there is no index 1 in the string '?'.

If a query parameter cannot be found based on its index, it should not be searched based on the key in such case as it triggers a PHP error in array_key_exists.
Merge remote-tracking branch 'doctrine/master'