db_select with mysql reserved word in the statement This seems to be fairly easy question, but I could not find simple answer to it. 

Using db_select when database column happens to be a reserved mysql word (when in this case) results in an error.

Table:

+-----------------------------------+------------+--------+
|               sort_id             |    when    |  user  |
+-----------------------------------+------------+--------+
| 1                                 | 1448270950 |    123 |
| 3                                 | 1448270955 |     12 |
| 50                                | 1448270959 |     45 |
+-----------------------------------+------------+--------+


Standard drupal7 select using db_select:

$query = db_select('my_table', 'd')
    -&gt;fields('d', array('sort_id', 'when', 'user'))
    -&gt;condition('user', $uid)
    -&gt;execute();


BUT column named when is the problem here.

I know I can write the query using plain SQL:

db_query("SELECT sort_id, user, `when` FROM {naughty_table} WHERE user = :user", array(":user" =&gt; $user_id));


But there should be a way to solve this using regular db_select?

IMPORTANT:

I have tried to use backticks like this:

$query = db_select('my_table', 'd')
    -&gt;fields('d', array('sort_id', '`when`', 'user'))
    -&gt;condition('user', '123')
    -&gt;condition('`when`', '1448270950')
    -&gt;execute();


But backticking like this does not seem to work whatsoever.
You can use where() instead:

$query = db_select('my_table', 'd')
  -&gt;fields('d', array('sort_id', '`when`', 'user'))
  -&gt;condition('user', '123')
  -&gt;where('`when` = :timestamp', array(':timestamp' =&gt; 1448160590))
  -&gt;execute();


Produces:

SELECT d.sort_id AS sort_id, d.when AS when, d.user AS user
FROM 
{my_table} d
WHERE  (user = :db_condition_placeholder_0) AND (`when` = :timestamp)