I have an Entity with an attribute defined as follows:
/** * @var integer * * @ORM\Column(name="weight", type="integer") */ private $weight;
I tried to solve the error and used var_dump () to find out what was going on ...
Answer:
string '20' (length=2)
I don't understand why $ weight is returned as a string ... shouldn't it be integer?
int 20
Or should I handle this in my business logic?
Edit (as I called var_dump ()):
I have a class called "Calculator" that iterates over $ items and uses the $ weight attribute. Something like that:
Controller:
$calculator->calculate($category->getItems());
Calculator:
foreach($items as $item) {
Edit (database column layout):
Here is the field in the database:
weight int(11)
source share