C5-8.4* Doctrine returns some values, and doesn't return others

Permalink
Here's how car model and associated car category ID columns are created:
/**
     * @ORM\Column(type="string")
     */
    protected $model;
    public function setModel($model)
    {
        $this->model = $model;
    }
    public function getModel()
    {
        return $this->model;
    }
    /**
     * Many Cars have One Category
     * @ORM\ManyToOne(targetEntity="Car\CarCategory")

I can get the car model in the view as
<?php echo  $car->getModel(); ?>

but I can't get the car category ID as
<?php echo  $car->getCategoryID(); ?>

Why not? What's so different about the getCategoryID?

 
alboraus replied on at Permalink Reply
It's a miracle. I spend half a day trying to figure something out and when all possible options seem to be exhausted, I write a question in the Forum and then miraculously 5 min right after that I find an answer I could not find for the past hours!.. )))

It turns out the $car->getCategoryID() returns only an object of the referenced category, to get the ID you actually have to ask again:
<?php echo $car->getCategoryID()->getCategoryID(); ?>

Anyone find working with Doctrine fun? )))
A3020 replied on at Permalink Best Answer Reply
A3020
You should rename the property 'categoryID' to 'category'. Then rename `getCategoryID` to `getCategory`. Then it will all make sense.
alboraus replied on at Permalink Reply
Yes, good point, this makes sense. Thank you for the advice.