且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用Redbean PHP和日期的数据格式不正确-存储为VARCHAR(255)

更新时间:2023-11-08 08:07:10

在RedBeanPHP 3之前的版本中,您可以使用优化器: http://www.redbeanphp.com/extra/optimizer 如果可能的话,它基本上会在以后更改列.

In RedBeanPHP versions older than 3 you can use an optimizer: http://www.redbeanphp.com/extra/optimizer It basically changes columns afterwards if possible.

您必须自己将优化器附加为侦听器.因为我已经看到人们对此感到挣扎,所以我删除了该系统,并将其替换为更原生的方法.现在,您只需分配SQL格式的日期或日期时间值,即可使用正确的数据类型创建该列.但是,如果该列已经用于存储其他数据,则该列将不会更改(这是为了保留该列中已经存在的数据).

You have to attach the optimizer yourself as a listener. Because I have seen people struggle with this I removed this system and replaced it for a more native approach. You can now just assign SQL formatted date or date-time values and the column will be created using the right data type. However if the column has already been used to store other data, the column will not change (this is to preserve the data already in the column).