![]() |
Getting DB data as correct PHP types directly - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30) +--- Thread: Getting DB data as correct PHP types directly (/showthread.php?tid=90977) |
Getting DB data as correct PHP types directly - Muzikant - 05-30-2024 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. RE: Getting DB data as correct PHP types directly - kenjis - 05-30-2024 Set numberNative to true: https://github.com/codeigniter4/CodeIgniter4/blob/dcbcf3828d350de7036a86f52a7e5127c969298e/app/Config/Database.php#L45 See numberNative in https://codeigniter.com/user_guide/database/configuration.html#explanation-of-values RE: Getting DB data as correct PHP types directly - Muzikant - 06-01-2024 Thank you. It was helpful. |