Answer the question
In order to leave comments, you need to log in
OneToOne connection does not work (Doctrine v2.5.14). What could be the problem?
There are 2 entities
/**
* Catalog
*
* @ORM\Table(name="catalog", indexes={@ORM\Index(name="position_idx", columns={"position"})})
* @DoctrineAssert\UniqueEntity(fields="url", message="URL должен быть уникальным")
* @ORM\Entity
*/
class Catalog
{
/**
* @var CatalogTemplate
*
* @ORM\OneToOne(targetEntity="CatalogTemplate", mappedBy="catalog", cascade={"persist"})
**/
private $template;
}
/**
* CatalogTemplate
* @ORM\Entity
* @ORM\Table(name="catalog_template")
*/
class CatalogTemplate
{
/**
* @ORM\OneToOne(targetEntity="Catalog", inversedBy="template")
* @ORM\JoinColumn(name="catalog_id", referencedColumnName="id")
*/
private $catalog;
}
$catalog->getTemplate()->getId();
Call to a member function setValue() on null
Answer the question
In order to leave comments, you need to log in
MAIN rule when updating the database, do not forget to add --env=prod
for the command php bin/console doctrine:cache:clear-metadata =)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question