Answer the question
In order to leave comments, you need to log in
How to add entity property in Zend Framework 2, ORM Doctrine?
Good time of the day. The situation is the following. The module has an entity associated with a database table. It is required to add two persisted fields to it. But for some reason ORM does not store their values in the database.
Did the following:
1) Added to the class declaration
/**
* @ORM\Column(type="string", name="description", nullable=true)
* @var string
* @author gleb.mihalkov
*/
private $description;
/**
* @ORM\Column(type="string", name="image", nullable=true)
* @var string
* @author gleb.mihalkov
*/
private $image;
/**
* Returns stock's image url.
* @return string
* @author gleb.mihalkov
*/
public function getImage()
{
return $this->image;
}
/**
* Sets URL of stock's image.
* @param string $url - Url of stock's image.
* @author gleb.mihalkov
*/
public function setImage($url)
{
$this->image = $url;
return $this;
}
/**
* Gets description of stock.
* @return string
* @author gleb.mihalkov
*/
public function getDescription()
{
return $this->description;
}
/**
* Sets description of stock.
* @param string $value - Value of new description.
* @author gleb.mihalkov
*/
public function setDescription($value)
{
$this->description = $value;
return $value;
}
Answer the question
In order to leave comments, you need to log in
Since you didn't show the full listing of the entity files, the only thing that comes to mind is that your entity mapping is, for example, in YAML, and for new fields you do it in annotations.
In general, try to validate the mapping. Also, try schema:create and see if your fields are in the resulting SQL. For example, like this:orm:schema-tool:create --dump-sql
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question