theillo Posted October 1, 2019 Share Posted October 1, 2019 I'm fetching some stuff from a DB, and it seems like every column is turned into a string, even if it's really an integer. Am I doing something wrong? $sql = 'SELECT * FROM `'._DB_PREFIX_.'mytable` WHERE id_assignment='.(int)$id_assignment.' ORDER BY position ASC' $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql); Link to comment Share on other sites More sharing options...
tdsoft Posted October 2, 2019 Share Posted October 2, 2019 Yes, what is your issue from this SQL? Link to comment Share on other sites More sharing options...
theillo Posted October 2, 2019 Author Share Posted October 2, 2019 (edited) It gives me string when I expect to get integers. so $result['id_product'] will be "38" instead of 38. Edited October 2, 2019 by theillo (see edit history) Link to comment Share on other sites More sharing options...
electriz Posted October 4, 2019 Share Posted October 4, 2019 On 10/2/2019 at 6:30 AM, theillo said: It gives me string when I expect to get integers. so $result['id_product'] will be "38" instead of 38. So you can cast it as integer, for example: $idProduct = (int)$result['id_product']; 1 Link to comment Share on other sites More sharing options...
theillo Posted October 7, 2019 Author Share Posted October 7, 2019 Of course, but it will require me to do this manually and I'll have to know which field has which type... So it's expected behavior of executeS() to turn every value into a string? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now