Swoole-src: MySQL numerical columns returning as strings

Created on 5 Nov 2019  ·  4Comments  ·  Source: swoole/swoole-src

When using the MySQL coroutine client, if I query a table with numerical columns, I get strings in the resulting array.

Is there a way to get metadata for the columns so that we can parse the numerical columns as actual numbers?

question

Most helpful comment

@osrec method prepare is defined in the \Swoole\Coroutine\MySQL class.

All 4 comments

MySQL server always return data as strings if you use query
But you can get numerical columns by $client->connect([..., 'strict_type' => true])
Or you can use prepare + execute (it's better)

Thanks @twose ! Is the prepare method now part of the swoole mysql class?

@osrec method prepare is defined in the \Swoole\Coroutine\MySQL class.

Great, thank you

Was this page helpful?
0 / 5 - 0 ratings