getResultArray return types |
Hi!
Mysql example select; Code: product.ProductID, but all result types "string". i want result types in array; ProductID -> int Title ->string CostPrice -> float Price -> float sorry for my bad english.
If you really need the values that way then why not type cast them?
PHP - Type Casting What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
(05-22-2022, 07:53 AM)ulas Wrote: Hi! For int, you can use intval() Read here on w3school For float, you can use floatval() Read here again Strings are OK, nothing would be needed. My advice, for prices go with Decimal on your database, not with float.
See the answer here on Stackoverflow.
When you select data from a MySQL database using PHP the datatype will always be converted to a string. You can convert it back to an integer using the following code: Code: $id = (int) $row['userid']; Or by using the function PHP Code: intval(): $id = intval($row['userid']);
(05-24-2022, 03:03 AM)demyr Wrote: See the answer here on Stackoverflow. I follow the link on Stack Overflow, and I've gotten some new thoughts. Thank you for providing a better answer to this problem. |
Welcome Guest, Not a member yet? Register Sign In |