问题处理日期在教义php [英] Issue handling dates in doctrine php

查看:116
本文介绍了问题处理日期在教义php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到日期格式问题。我正在使用mysql,doctrine2和php 5.3。

I am having a issue with a date format issue. I am using mysql, doctrine2, and php 5.3.

当我查询数据库 getRepository('Entity\\\Srm')时,问题是findBy($ id)我的结尾是一个负数值: -0001-11-30 00:00:00

The issue is when I query the database getRepository('Entity\\Srm').findBy($id) I end up with a negative date value of: -0001-11-30 00:00:00.

当前存储在数据库中的值为 0000-00-00 。 mysql中的字段数据类型为 date

The value that is currently store in the database is 0000-00-00. The datatype of the field in mysql is date.

原则实体的变量标识为日期类型。

The doctrine entity has the variable identified as a date type.

我已经做了大量的搜索,没有好的潜在客户。

I have done tons of searching with and no good leads.

任何想法?

感谢

推荐答案

我找到了解决问题的办法。我已经在实体的属性上设置了注释,所以我决定删除注释,以便PHP处理它们。现在它正在工作,因为它被查询为字符串类型,而不是日期类型。我想这是我从静态世界和动态世界中得到的。

I found the solution to my problem. I had the annotations set to date on the attributes in the entities, so I decided to remove the annotations in order to PHP handle them. Now it's working since it is queried as a string type and not date type. I guess this is what I get coming from the static world vs. the dynamic world.

这篇关于问题处理日期在教义php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆