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
Posted (edited)

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

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