You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Positional parameter at index 0 does not have a bound value error for question marks used within quotes.
Current behavior
MySQL query like the following:
SELECT my_question AS 'Why do you like turtles?'
FROM...
Causes an error: "Positional parameter at index 0 does not have a bound value." despite being enclosed in single quotes.
Modifying the query as follows:
SELECT my_question AS 'Why do you like turtles??'
FROM...
Returns two question marks in the result instead of one. As far as I can tell there is no way to use question marks in field aliases.
Expected behavior
I would expect the question mark to be treated as a literal within single quotes. Or, if that is not the case, I'd expect the escaped question mark to return a single question mark.
P.S. I am not using the query builder to perform this query. The code and query ran fine in Laminas DB. I am currently porting to Doctrine DBAL.
The text was updated successfully, but these errors were encountered:
It looks like the problem is actually the apostrophe mixed with a question mark.
SELECT my_question AS 'Why you''d like turtles?'
FROM...
Seems to work
But
SELECT my_question AS 'Why you\'d like turtles?'
FROM...
Causes an exception, shouldn't either work?
The problem seems to be caused with the combination of "\'" and "?" if I remove the question mark the problem also goes away. It must trip some strange case when parsed.
Bug Report
pdo_mysql driver
Summary
Positional parameter at index 0 does not have a bound value error for question marks used within quotes.
Current behavior
MySQL query like the following:
SELECT my_question AS 'Why do you like turtles?'
FROM...
Causes an error: "Positional parameter at index 0 does not have a bound value." despite being enclosed in single quotes.
Modifying the query as follows:
SELECT my_question AS 'Why do you like turtles??'
FROM...
Returns two question marks in the result instead of one. As far as I can tell there is no way to use question marks in field aliases.
Expected behavior
I would expect the question mark to be treated as a literal within single quotes. Or, if that is not the case, I'd expect the escaped question mark to return a single question mark.
P.S. I am not using the query builder to perform this query. The code and query ran fine in Laminas DB. I am currently porting to Doctrine DBAL.
The text was updated successfully, but these errors were encountered: