30

I have a column in my table with DECIMAL(19,4) and I'm creating my Entity for a project, what is the right way to define this field? What precision and scale parameters means in Doctrine Annotations?

Touki
  • 7,465
  • 3
  • 41
  • 63
Reynier
  • 2,420
  • 11
  • 51
  • 91

1 Answers1

61

The precision is the number of digits in the number. For example, 123456.78 has a precision of 8.

Scale is the is the maximum number of decimal places. 123456.78 has a scale of 2.

DECIMAL(19,4) would allow 19 total digits, with four decimal places.

The annotation for that would be:

@Column(type="decimal", precision=19, scale=4)
Francesco Casula
  • 26,184
  • 15
  • 132
  • 131
StuBez
  • 1,346
  • 14
  • 21