Why do the database functions return all fields as strings? db_select('my_table', 'a')
   -&gt;fields('a')
   -&gt;condition('a.campaign_id', $entity-&gt;campaign_id)
   -&gt;execute()
   -&gt;fetchObject();


my_table has some columns that are integers, but the query above returns strings.

Why does this happen? It seems strange to me that the query ignores the column types.
The DatabaseStatementBase::fetchObject() method is inherited from PHP's PDOStatement::fetchObject() which returns the object columns as strings. Given that not all RDBMS's have the same set of types &amp; PHP isn't a strongly typed language, it was probably decided to return everything as strings since it's a base datatype that can be relied on.