Welcome Guest, Not a member yet? Register   Sign In
Get query results as their native data type?
#1

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
Reply
#2

(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 );
Reply




Theme © iAndrew 2016 - Forum software by © MyBB