Closed Guervyl closed 7 months ago
Invalid datetime format? :thinking:
Sorry this has nothing to do with bundle
Actually it is a doctrine error. I leave a video to see a live error https://drive.google.com/file/d/11q61P4phZWWW2McDauut5ilW5ZOMPiBl/view?usp=sharing
Doctrine != doctrine-bundle. We just provide wiring for doctrine/dbal and doctrine/orm. Look at this:
There are no usages of Doctrine\Bundle
, so this is a wrong repository.
But also, this is unlikely a problem in any of the doctrine repositories. This is more like issue with db encoding/configuration. Better to create a stackoverflow post I would say.
and also better providing a reproducing case
Cool. I just found a fix. I had to pass the query parameters charset=utf8mb4&collation=utf8mb4_unicode_ci
to the connection string.
I have a Symfony project using doctrine. When the text has emoji to insert in the database I get the error
An exception occurred while executing a query: SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect string value: '\xF0\x9F\xA4\x97Gr...' for column ....
I have search the web and the said to change the database charset to
utf8mb4
and I did change toutf8mb4_general_ci
. The database I'm using ismariadb 10.6.5
. I can confirm that the problem is not the database because using phpmyadmin I can execute the insert query successfully and it saves with the emoji. But using Doctrine I keep getting the error.The stack trace is:
And the text is
🤗Gracias por comunicarse....
The real mysql error is
An exception occurred while executing a query: SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect string value: '\\xF0\\x9F\\xA4\\x97 G...' for column....
If I remove the emoji it works fine.