0

I am trying to run a select statement on a table for a column. The column is decimal(20,0) unsigned.

A majority of the entries can be found using the select statement:

db_query('SELECT * FROM {foo_table} WHERE foo_id = :other_id',array(':other_id' => $value))

and $value is a string holding a large number, and example number is 395589699550470144

I believe that query is treating the $value as a string for some of the larger numbers. Now this query works.

db_query("SELECT * FROM {foo_table} WHERE foo_id = $value")

But this query is insecure due to user input method.

Is there a way to force the query to always convert the string to a number safely?

2
  • Welcome to Drupal Answers :) What problem are you actually having? Is your first example not bringing back the correct results? Is your server running on 32 or 64 bit architecture?
    – Clive
    Oct 31, 2013 at 22:12
  • The problem is that the first query doesn't work for all values, but the second does. The version of php is 5.3 and 32 bit, I have no control over the environment.
    – Paul
    Nov 1, 2013 at 13:09

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.