Symfony3自动生成特定值

时间:2017-05-07 13:14:50

标签: php annotations symfony-3.1

我有一个名为User的实体,我有一个属性$ money。当有人注册我想用钱注册他总是从5000开始。我正在使用Symfony3,我想用注释来做。   例如,我有这个属性

/**
 * @var int
 *
 * @ORM\Column(name="id", type="integer")
 * @ORM\Id
 * @ORM\GeneratedValue(strategy="AUTO")
 */
private $id;

我正在尝试使用相同类型的注释,但始终生成相同的值。到目前为止,这是我的注释金钱

/**
 * @var int
 *
 * @ORM\Column(name="money", type="integer")
 * @ORM\GeneratedValue()
 */
private $money;

我的问题是我不知道在括号之间放什么,即使这是正确的方法。

2 个答案:

答案 0 :(得分:2)

很抱歉,但我不认为有一种方法可以做到这一点与annontations。你能做的是:

/**
 * @var int
 *
 * @ORM\Column(name="money", type="integer")
 */
private $money = 5000;

这样一来,新用户在创建时总会有5000个。

答案 1 :(得分:0)

这是最好的方式:

 [NbConvertApp] Converting noteboo.ipynb to pdf
 [NbConvertApp] Writing 350653 bytes to notebook.tex
 [NbConvertApp] Building PDF
 [NbConvertApp] Running pdflatex 3 times: ['pdflatex', 'notebook.tex']
 [NbConvertApp] Running bibtex 1 time: ['bibtex', 'notebook']
 [NbConvertApp] WARNING | bibtex had problems, most likely because 
 there were no citations
 [NbConvertApp] PDF successfully created
 [NbConvertApp] Writing 208111 bytes to notebook.pdf
相关问题