Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The returned field of PDO query mysql is changed to String scheme

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the PDO query mysql return field into String scheme, I hope you can add and update some knowledge, if you have other questions you need to know, you can continue to follow my updated article in the industry information.

PDO query mysql returned field integer becomes string type solution

When querying the mysql database using PDO, after executing prepare,execute, the returned field data is all character-typed.

For example, id is Int in the database and returns string after query.

For a weakly typed language like php, it has little impact. When API returns data, if the type is not consistent with the database, it will have a great impact on strong types such as java and Objective C.

Solution:

The function of these two sentence settings

PDO::ATTR_STRINGIFY_FETCHES converts a numeric value to a string when it is extracted.

PDO::ATTR_EMULATE_PREPARES enables or disables impersonation of preprocessed statements.

For more PDO setAttribute, please see:

This article explains the solution of changing the returned field integer to string through PDO query mysql. Please follow us for more information.

Related recommendations:

Through php, we can obtain the data of country, province, city and surrounding area according to the geographical coordinates.

Related methods of how to use the glob method to traverse all files under a folder

Explanation on the comparison method of php floating Point numbers

These are the details of the solution to change the returned field integer into string through PDO query mysql. Please pay more attention to other related articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 290

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report