0

I'm struggling with a Doctrine - MySQL microsecond issue. I've already done my research as you can read here: Enabling microseconds in Symfony2 (Doctrine) and MySQL

It appears that the solution might come from what I read here http://doctrine-dbal.readthedocs.org/en/latest/reference/types.html that "datetime" is mapped to DATETIME (instead of DATETIME(6), even if MySQL 5.6 allows it), but the footnote says that DATETIME is

Chosen if the column definition not contains the version option inside the platformOptions attribute array or is set to false which marks it as a non-locking information column.

So I imagine there is a way to specify the version option in the column definition...but was not able to find how. Any idea?

EDIT: I also tried (as suggested below by @Ziumin) to do the following:

/**
* @ORM\Column(type="datetime")
* @ORM\Version
*/
protected $timestamp;

When I perform the following:

php app/console doctrine:schema:update --force

I get:

Updating database schema...
Database schema updated successfully! "1" queries were executed

But in practice nothing changed. The field is now a TIMESTAMP (not a DATETIME as before, nor a DATETIME(6) as it should be), with its fraction of second limitation.

Thank you!

Community
  • 1
  • 1
Sergio Negri
  • 2,023
  • 2
  • 16
  • 38
  • Mb you should try `@Version` annotation on your field? – Ziumin Dec 28 '14 at 15:48
  • 1
    Ok. I looked at doctrine sources. There is no DATETIME(6) support. It realy generates TIMESTAMP for @Version-ed fields. So the solution here is implementing own custom doctrine type, named `datetime6`, for example. http://doctrine-orm.readthedocs.org/en/latest/cookbook/advanced-field-value-conversion-using-custom-mapping-types.html – Ziumin Dec 28 '14 at 16:18
  • 1
    Thank you very much. It seems absurd that it's not provided out of the box, maybe mapping the fractions in an integer. I'm sure I'm not the only one with this problem. – Sergio Negri Dec 28 '14 at 17:03

0 Answers0