php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #81644 mysql native driver should use DateTime object
Submitted: 2021-11-20 10:56 UTC Modified: 2021-11-22 13:42 UTC
From: shop1 at mokraemer dot de Assigned:
Status: Suspended Package: MySQLi related
PHP Version: 8.0.13 OS: Linux
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2021-11-20 10:56 UTC] shop1 at mokraemer dot de
Description:
------------
if you use mysqli native driver, it fetches data and puts the data in the equivalent php datastructure. This is true for float, int, ...
But values for date,time and datetime are still strings. It would be great if this is converted automatical.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-11-20 11:47 UTC] heiglandreas@php.net
As PHP - at least currently - does not have native types for Date and Time there will be no possibility to convert those into Objects.

And I don't even want to tackle the topic of converting Datetime values with regards to timezones. As there is no "One size fits all" it is best to leave that up to the app.

And as the native mysqli driver only converts between native types I doubt that that is a thing that we should start.

If so, we would for sure need an RFC for that.
 [2021-11-20 21:10 UTC] shop1 at mokraemer dot de
Thanks for your comment. You're right about Date/Time we don't have anything in php for that.
For datetime and timestamp there is no problem with timezones. The conversion is done by mysql on the connection base. Anyway, now everyone who uses DateTime or timestamps from mysql in php needs to do convert that column to a DateTime object in order to do anything with the value from the database.
But maybe you're right this needs some more thinking and an RFC. Since RFC's are not easy to make for php, I guess this is the end of that idea.
 [2021-11-22 13:42 UTC] cmb@php.net
-Status: Open +Status: Suspended
 [2021-11-22 13:42 UTC] cmb@php.net
> Since RFC's are not easy to make for php, I guess this is the
> end of that idea.

Consider to *start* the RFC process[1] anyway (i.e. write to the
mailing list).  Maybe others are interested in this as well, but
it's unlikely those will see this ticket.

For the time being, I'm suspending this ticket.

[1] <https://wiki.php.net/rfc/howto>
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Thu Dec 01 07:05:54 2022 UTC