Yes, but it's incredibly difficult to do properly.
Swapping out database drivers is a piece of cake. If you use PDO, you can connect to different database drivers by passing a different DSN. PDO has drivers for SQLite, MySQL, PostgreSQL, Firebird, DB2, Microsoft's SQL Server, Oracle, ODBC devices, and probably some more that I'm forgetting about. If you use it sensibly, using prepared statements and the like, you don't even have to worry about the different databases having different escaping rules.
This isn't enough.
MySQL and Oracle don't speak the same dialect of SQL. They don't have the same features and capabilities. The features they have in common work differently. They have different performance characteristics. Indexing is different. Collations are different. Even basic things, like how to reference tables, or what kind of field types you can use, can differ drastically between databases.
Even if you managed to abstract all that away, and come up with some common subset of functionality you could use, chances are your application will be slow on both databases. In order to get decent performance out of any of these things, you need to be familiar with how they work, and you need to use the special features they offer.
Taking full advantage of each database typically requires changing the data model a bit. Particularly with MySQL and Oracle, which are almost as different as two databases can get.
The further apart the data models get, the more difficult it becomes to verify that your application actually works properly on both databases. It also becomes more difficult to migrate the data between the databases.
It's certainly not impossible, but it's a lot of work.