How to get an integer from MySQL as integer in PHP?

前端 未结 9 691
情话喂你
情话喂你 2020-12-31 03:26

When data is returned from MySQL, it is automatically returned as strings, regardless of the MySQL data type.

Is there any way to tell MySQL/PHP to maintain the data

9条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-31 04:18

    You could use type casting once you've pulled the data from your MySQL database

    $row['field'] = (int)$row['field'];
    

提交回复
热议问题