CodeIgniter Forums

Full Version: Get query results as their native data type?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I've a MySQL 5.6 database with an PHP7/Codeigniter3.1 app querying it. When I do a query and get the results with $query->get()->result_array() the array values are all strings and in the database some fields are defined as int.

Another app querying a SQL Server works ok with native data types.

I tried 'mysqli' and 'pdo' drivers, both with mysqlnd enabled.

Any tips?

THx
(02-16-2017, 07:31 AM)dimas Wrote: [ -> ]Hi,

I've a MySQL 5.6 database with an PHP7/Codeigniter3.1 app querying it. When I do a query and get the results with $query->get()->result_array() the array values are all strings and in the database some fields are defined as int.

Another app querying a SQL Server works ok with native data types.

I tried 'mysqli' and 'pdo' drivers, both with mysqlnd enabled.

Any tips?

THx

Always return string types, if you send request in json can do it some like that: json_encode( $results , JSON_NUMERIC_CHECK );