I am looking for a way to doctrine using TIMESTAMPinstead DATETIMEfor MySql.
TIMESTAMP
DATETIME
Additionally I need to set ON UPDATE CURRENT_TIMESTAMPand CURRENT_TIMESTAMPas default values.
ON UPDATE CURRENT_TIMESTAMP
CURRENT_TIMESTAMP
I would like to be able to have all this code in PHP annotations in order to have everything in one central place.
How can i do this?
There is no such thing as using TIMESTAMPin mysql using Doctrine. However, I fixed it myself, but I have to check:
Doctrine\DBAL\Types\TimestampType.php
TimeType.php
TimestampType.php
Doctrine\DBAL\Types\Type.php
getTimestampTypeDeclarationSQL
Doctrine\DBAL\Platforms\AbstractPlatform.php
yaml , yaml:
yaml
type: timestamp
"" / " ". .
, , - , WRONG ( TIMESTAMP - datetime)
datetime
, ,
* @ORM\Column(type="datetime", nullable=false) * @ORM\Version
, Doctrine TIMESTAMP DEFAULT CURRENT_TIMESTAMP, \DateTime.
DEFAULT CURRENT_TIMESTAMP
\DateTime
CTOP (Credits to Original Poster)
@ , . . , :
GitHub:
.. , , , . , .
/** @ORM\Column(type="datetime", nullable=false ) */ protected $created;
timestamp return datetime
public function __construct() { $this->created = new \DateTime(); }
/** * @Column(type="datetime", options={"default": 0}) * @version=true */ private $data;
sql : data TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL
data TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL
2.5.4
@ORM\Version , , .
Daniel Criconet,
@ORM\Column(type="datetime", columnDefinition="TIMESTAMP DEFAULT CURRENT_TIMESTAMP")
MySQL TIMESTAMP DATETIME.
YAML . .