[eluser]tonanbarbarian[/eluser]
firstly i always use AR if i can, but it is not possible in every situation
having said that with the exception of a couple of things like rand, it is easily possible to always write SQL that is usable in every database. DEspite working almost exclusively in MySQL for the last 10 years I still right standard SQL statements that I know will work in all databases.
What a lot of people dont remember is that if you want your database to be able to be installed on any database it is not just the SQL statements during the app that must be standard, it is the table structures themselves.
For this reason I always do the following
1. I never use views or stored procedures. While most databases support these the syntax and or implementation of them can be so varied it is not worth attempting to make them cross platform
2. Max length for varchar fields is 254. Since that is the lowest max length I have found in my research I always use that rather than 255 or higher
3. I never use non standard field types such as enum
4. and of course i always look at how much data actually needs to be stored in a field and set the parameters accordingly. Why waste space if you dont need to.
The one thing I do do is use autoincrement, despite not all database engines supporting this. But frankly if there is a database that cannot do autoincrement or implement a simple equivalent then it is not worth using, no matter how popular it may be