2

I understand that in general PDO scripts are cross compatible i.e. generally changing the connection string should work.

In the past I've spent hours searching online after changing a PDO script connection string from MySQL to SQLite as this isn't the case, some things don't work the same (I remember an issue with row counting or something).

So should changing from MySQL to Oracle be generally simple, or are there things to watch out for as in the SQLite case?

user4166144
  • 251
  • 2
  • 12
  • 2
    Short answer: No. The two have a lot of incompatibility on the SQL syntax layer. – tadman Dec 10 '14 at 21:47
  • It depends. MYSQL, Oracle and SQLite all have different dialects of SQL and different levels of support. Some queries will execute on all three whilst others will need tweaking or rewriting altogether. –  Dec 10 '14 at 21:47

1 Answers1

3

So should changing from MySQL to Oracle be generally simple, or are there things to watch out for as in the SQLite case?

There are things to watch out.


More seriously, beside basic SQL query, each RDBMS has its own set of specific features that have to be taken into account. Just to give one example, if you want to limit the result set to one row only, MySQL provides the LIMIT clause. But for Oracle up to 11g, you need a sub-query for that purpose.

If you really need cross-vendor support, you probably should take a look at some library providing database abstraction layer whose job is to allow you to write database-agnostic code. PDO isn't such a library. But Doctrine DAL, Zend_db and many other are.

It is now considered as off-topic to request suggestions for a tool here, but take a look at this old question if you need few pointers: Best PHP DAL (data abstraction layer) so far

Community
  • 1
  • 1
Sylvain Leroux
  • 50,096
  • 7
  • 103
  • 125