开发者

Zerofill with Doctrine2

开发者 https://www.devze.com 2023-03-10 03:18 出处:网络
It looks like an easy task, but I can\'t get it done: How do I def开发者_如何学Pythonine a column to be UNSIGNED ZEROFILL with Doctrine2?

It looks like an easy task, but I can't get it done:

How do I def开发者_如何学Pythonine a column to be UNSIGNED ZEROFILL with Doctrine2?

I can't find any information about it in the docs.

Thx for any help!


Do you need it on database level or is it required only by the application? You could append zeros on the application level:

class MyEntity {
    public function getSomeColumn() {
        return sprintf('%05d', $this->someColumn); // or str_pad(...)
    }
}

However if you really need it on database level then you'll have to annotate the column as a string: @Column(type="string", columnDefinition="UNSIGNED INTEGER(5) ZEROFILL")


The good syntax is :

@Column(type="integer", columnDefinition="INT(5) UNSIGNED ZEROFILL")


Use the (non-portable) columnDefinition property in the @Column annotation.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号