SELECT month(from_unixtime(s.date)) AS month, count(s.id) AS blah, s.status FROM Something s WHERE s.date between unix_timestamp($blah) and unix_timestamp($blah) GROUP BY s.status, month
I used MySQL platform specific commands like month, from_unixtime and unix_timestamp.
How can I re-write this query to make it cross-platform compatible that it works on PostGre too?
There have been attempts to do that, for example Doctrine Query Language in PHP, have a look at the functions. I’m not personally fond of this monstrous ORM library so I haven’t used DQL myself. But you would need to use some sort of SQL abstraction layer in your code to make your queries work in multiple database engines.