FaaPz / PDO

Just another PDO database library
MIT License
316 stars 103 forks source link

Doesn't support DATE/TIME types in WHERE clause #45

Closed stevevance closed 5 years ago

stevevance commented 8 years ago

I don't know if this is a problem with PDO or with this library.

I am trying to use this WHERE clause:

->where("date", ">", "CURRENT_DATE - INTERVAL '90 days'")

but I get this exception:

Uncaught exception 'PDOException' with message 'SQLSTATE[0A000]: Feature not supported: 7 ERROR:  date/time value "current" is no longer supported' in .../vendor/slim/pdo/src/PDO/Statement/StatementContainer.php:404

Is it possible to use DATE/TIME variables in PostgreSQL like CURRENT_DATE?

stevevance commented 8 years ago

The alternative and successful way to use date intervals is to calculate the interval in PHP:

->where("issue_date", ">", date("Y-m-d", strtotime("90 days ago")))
kwhat commented 5 years ago

@stevevance sorry for the delay... I have address this in 2.x with the Raw SQL clause:

->where("date", ">", new Raw("CURRENT_DATE - INTERVAL '90 days'"))