Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set charset on Connect/LazyConnect? #116

Closed
recarv opened this issue Dec 12, 2019 · 3 comments
Closed

set charset on Connect/LazyConnect? #116

recarv opened this issue Dec 12, 2019 · 3 comments

Comments

@recarv
Copy link

recarv commented Dec 12, 2019

Hello,

We're running into issues while testing on mySQL8 whereby we're getting errors like:

Error: Incorrect DATE value: ''"

when passing a query like "select * from table where datecol='2019-04-01'". Our first inclination was it was a sql_mode problem (as that what most google hits lead), except the date value we're using in the where statement is valid.

After a good deal of debugging we believe it has to do with query being passed in without an explicit ability to indicate the client's charset. For example, when using a PDO connection and a DSN string like the following:

$dsn="mysql:host=" .$shard_host.";port=".$shard_port.";dbname=mysql;charset=utf8";

The proper result is returned. However if we convert this to the URI format required for this library:

$uri=user:pass@host:port/mysql

We receive the error mentioned above.

We also tried:

$uri=user:pass@host:port/mysql?charset=utf8

to see if this might work, but it does not. How can we explicitly set the client charset so that the server interprets this correctly?

@ghost
Copy link

ghost commented Feb 23, 2020

Explicitely send a SET NAMES "utf8mb4" query. Explicit support for setting the charset and collation should probably be added to this library, as I've added to my project https://github.com/PlasmaPHP/driver-mysql/blob/3d706bef7c0cc96235c2931a2413dd972fad5b5a/src/Driver.php#L269. PRs for this are probably accepted.

@clue
Copy link
Contributor

clue commented Jan 25, 2021

@recarv Thanks for bringing this up!

I agree sending a SET NAMES "utf8mb4" query is probably a good idea 👍

We've successfully used this library to send UTF-8 data back and forth with MySQL. I don't see how this could be related to the error you're seeing otherwise.

I believe this has been answered, so I'm closing this for now. Please come back with more details if this problem persists and we can always reopen this 👍

@clue clue closed this as completed Jan 25, 2021
@clue
Copy link
Contributor

clue commented Dec 20, 2021

See also #135

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants