Welcome Guest, Not a member yet? Register   Sign In
Getting DB data as correct PHP types directly
#1
Question 
(This post was last modified: 05-30-2024, 03:20 AM by Muzikant.)

Hi. Is it possible to get data from database as correct PHP types directly without retyping them?

For example:
TINYINT, INT, BIGINT as integer
FLOAT, DOUBLE, DECIMAL as float
CHAR, VARCHAR, TEXT as string

I do not care about dates as date type. Now everything, except of null, are strings. I am using MySQL database.
Reply
#2

Set numberNative to true:
https://github.com/codeigniter4/CodeIgni...se.php#L45
See numberNative in https://codeigniter.com/user_guide/datab...-of-values
Reply
#3

Thank you. It was helpful.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB