• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
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


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.