Search code examples
phpmysqlsqlpdoabstraction

How to use PDO for database-specific functions?


I need to use specific functions in MySQL which I'm not sure is available in other DB flavors. E.g.,

SELECT DATE_SUB(mydate, INTERVAL 5 DAY) AS foo FROM table

What is the best practice for cases like this when using PDO?

Edit:

What I mean to ask is, how can I make sure DATE_SUB will also work in all DB flavors that supports PDO?


Solution

  • how can I make sure DATE_SUB will also work in all DB flavors that supports PDO?

    You can't.

    If you want a database-independent layer, look at the Doctrine