danielmewes / php-rql

A PHP client driver for the RethinkDB query language (ReQL).
http://php-rql.dnsalias.net/
339 stars 60 forks source link

Idea: accept \DateTime on insertion #117

Open thijsw opened 8 years ago

thijsw commented 8 years ago

Hi,

First and foremost, thanks for making this client :)

As a suggestion, I would propose an idea that will make the insertion of dates to the database a bit easer (at least for me).

I'd like to be able to save \DateTime instances such that the dates are stored in the native manner, just like with \r\now(), handle by the client. Another option to make this easier would be to include a static method in r\Queries\Dates\Time, e.g. fromDateTime that accepts a \DateTime and yields a new Time object, that can be used for insertion.

Maybe this is already possible and I am missing something, but I couldn't find any information about in the docs.

Any ideas?

danielmewes commented 8 years ago

Hi @thijsw . Sorry for my late response. This should already be working. It's just not documented right now.

If you run r\expr(new \DateTime(...))->run($conn) you should get another \DateTime object back, despite it being sent to the server first.

Let me know if there are any issues.