Jump to content
theillo

Does executeS() turn every value into a string?

Recommended Posts

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);

 

Share this post


Link to post
Share on other sites

It gives me string when I expect to get integers.

so $result['id_product'] will be "38" instead of 38.

Edited by theillo (see edit history)

Share this post


Link to post
Share on other sites
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'];

  • Like 1

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More